//fileSize begin
//换算文件大小
a.fileSize = function(size){
    var unit = "B";
    if(size > 1024){
        size = Math.ceil(size / 1024);
        unit = "Kb";
        if(size > 1024){
            size = parseInt(size / 1024 * 100) / 100;
            unit = "Mb";
        }
    }
    return size + unit;
}
//fileSize end
//----------------------------------公共组件----------------------------------------------
//creatCover begin
//遮罩
a.creatCover = function (args) {
    args = args || {};
    var id = args.id || 'creatCover', obj = args.obj;
    var left = 0;
    var top = 0;
    var width = 0;
    var height = 0;
    if (obj == window || !obj || obj == $(window) || obj[0] == window) {
        width = $(window).width();
        height = $(window).height();
        $("body").append("<div id='" + id + "'></div>");
        if(!args.unScroll0) $(window).scrollTop(0);
    } else {
        left = obj.offset().left;
        top = obj.offset().top;
        width = obj.width();
        height = obj.height();
        obj.append("<div id='" + id + "'></div>");
        if(!args.unScroll0) obj.scrollTop(0);
    }
    var styles = {
        position: args.position || 'absolute',
        zIndex: args.zIndex || a.zIndex(4),
        left: left + 'px',
        top: top + 'px',
        opacity: !args.opacity && args.opacity != 0 ? 0.01 : args.opacity,
        background: args.background || '#ffffff',
        width: (obj == window || !obj ? "100%" : width + 'px'),
        minHeight: height + 'px'
    }
    if(args.styles) for(var key in args.styles) styles[key] = args.styles[key];
    $("#" + id).css(styles);
}
//creatCover end
//loading begin
a.loading = function (args) {
    args = args || {};
    var opacity = args.opacity || 0.1;
    this.msg = args.msg || "";
    this.isOpen = false;
    this.rgba = "255,255,255," + opacity;
    this.color = "#000000";
    this.imageSrc = '<div class="loadEffect" style="transform:scale(0.5,0.5);margin-top: 50px;"><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span></div>';
    this.image = $(this.imageSrc);
    this.loadBoxStyle = args.loadBoxStyle;
    this.id = null;
    this.open = function (msg, rgba, color) {
        this.id = "load" + (new Date()).only();
        if (!this.isOpen) {
            msg = msg == undefined ? this.msg : msg;
            rgba = rgba == undefined ? this.rgba : rgba;
            color = color == undefined ? this.color : color;
            var loadText = "<div>" + msg + "</div>";
            var loadBoxStyle = "";
            a.creatCover({id:this.id + "_cover",obj:this.obj,zIndex:args.zIndex || a.zIndex(4),opacity:0,background:"#ffffff",unScroll0:true});
            if(!this.loadBoxStyle){
                if(!this.obj){
                    loadBoxStyle = "text-align:center;border-radius :5px;height:100px;width:100px;position:fixed;z-index:" + (args.zIndex || a.zIndex(4)) + ";background:rgba(" + rgba + ");color:" + color + ";left:" + (($(window).width() - 100) / 2) + "px;top:" + (($(window).height() - 100) / 2) + "px";
                }else{
                    loadBoxStyle = "text-align:center;border-radius :5px;height:100px;width:100px;position:fixed;z-index:" + (args.zIndex || a.zIndex(4)) + ";background:rgba(" + rgba + ");color:" + color + ";left:" + ((this.obj.width() - 100) / 2 + this.obj.offset().left) + "px;top:" + ((this.obj.height() - 100) / 2 + this.obj.offset().top) + "px";
                }
            }else{
                loadBoxStyle = this.loadBoxStyle;
            }
            $("body").append("<div id='" + this.id + "' style='" + loadBoxStyle + "'>" + this.imageSrc + loadText + "</div>");
            this.isOpen = true;
        }
    },
    this.close = function () {
        this.isOpen = false;
        $("#" + this.id + "_cover").remove();
        $("#" + this.id).remove();
    },
    this.status = function () {
        return this.isOpen;
    }
}
//loading end
//confirmx begin
a.confirmx = function (s,fn,args) {
    args = args || {};
    var w = new a.Windows(args);
    w.width = args._w || 300;
    w.height = args._h || 150;
    w.title = args.title || "提示";
    w.style = args.style;
    w.styles = args.styles;
    w.bodyScrollNo = args.bodyScrollNo ? true : false;
    w.cancleFn = args.cancleFn;
    w.content = "<div style='text-align: center;' id='alertContent" + w.id + "'>" + s + "</div>";
    w.bottom = args.noBtns ? "" : "<div style='text-align: right;margin-right:10px;margin-top: 10px;'><span id='alertOk" + w.id + "' style='padding:5px 15px; border-radius: 3px;cursor: pointer;margin-right:10px;background:#00b7ee;color:#fff'>确定</span><span id='alertCancle" + w.id + "' style='padding:5px 15px; border: 1px solid #e4e4e4; border-radius: 3px;cursor: pointer;'>取消</span></div>";
    w.open();
    if(args.initFn) args.initFn();
    var windowContentHeight = $('#' + w.id + '_content').height();
    var contentHeight = $("#alertContent" + w.id).height();
    if(contentHeight < w.height){
        $("#alertContent" + w.id).css("padding-top",((windowContentHeight - contentHeight) / 2) + "px");
    }
    $("#alertOk" + w.id).click(function () {
        if(args.verifyFn){
            if(args.verifyFn()){
                if (fn) fn();
                w.close(true);
            }
        }else{
            if (fn) fn();
            w.close(true);
        }
    })
    $("#alertCancle" + w.id).click(function () {
        w.close();
    })
    return w;
}
//confirmx end
//alertx begin
a.alertx = function (s,fn,args) {
    args = args || {};
    var w = new a.Windows(args);
    w.closeBtn = args.closeBtn == true ? true : false;
    w.width = args.width || 300;
    w.height = args.height || 150;
    w.title = args.title || "提示";
    w.style = args.style;
    w.styles = args.styles;
    w.content = "<div style='text-align: center;' id='alertContent" + w.id + "'>" + s + "</div>";
    w.bottom = "<div style='text-align: right;margin-right:10px;margin-top: 10px;'><span id='alert" + w.id + "' style='padding:5px 15px; border-radius: 3px;cursor: pointer;' class='bg_00b7ee'>确定</span></div>"; 
    if(args.toast){
        w.bottom = '';
        w.titleHeight = 0;
        w.bottomHeight = 0;
        w.styles = w.styles || {};
        w.styles.box = 'background:#000;background:rgba(0,0,0,0.7);color:#fff;border-radius:5px;';
        if(args.toast.position == 'top') w.styles.box += 'top:150px;';
        if(args.toast.position == 'bottom') w.styles.box += 'top:auto;bottom:50px;';
        w.cover = false;
    }
    if(!args.unOpen) w.open();
    if(args.toast) {//自动关闭
        if (fn) fn();
        setTimeout(function(){
            w.close();
        },args.toast.time || 3000);
    }
    var windowContentHeight = $('#' + w.id + '_content').height();
    var contentHeight = $("#alertContent" + w.id).height();
    if(contentHeight < w.height){
        $("#alertContent" + w.id).css("padding-top",((windowContentHeight - contentHeight) / 2) + "px");
    }
    $("#alert" + w.id).click(function () {
        w.close();
        if (fn) fn();
    })
    return w;
}
//alertx end
//tips begin
a.tips = function(s,args){
    args = args || {};
    var id = (new Date()).only();
    var bgColor = args.bgColor ? args.bgColor : "fcc463";
    var html = "<div id='tips" + id + "' style='padding:5px;position:fixed;width:100%;left:0;top:0;z-index:" + id + ";background:#" + bgColor + ";'><div>" + s + "</div><span id='tipsClose" + id + "' style='position:fixed;right:10px;top:5px;cursor:pointer;'>x</span></div>";
    $("body").append(html);
    if(args.time){
        setTimeout(function(){
            $("#tips" + id).remove();
        },args.time);
    }
    $("#tipsClose" + id).click(function(){
        $("#tips" + id).remove();
    })
}
//tips end
//Calendar begin
a.Calendar = function (obj, args) {
    args = args || {};
    var _this = this,date = args.date,type = args.type;
    this.type = type || "";//默认选择年月日的日历    year 只可以年份的日历  month 只选择年份及月份的日历
    this.date = new Date();//当前选择时间
    this.selectedDate = new Date();
    this.yearRange = [1900, 2060];//年限范围
    this.timeType = args.timeType || [];//长度 (0 无 1时 2分 3秒)
    this.boxStyles = args.boxStyles || '';
    this.maxDate = null;
    this.minDate = null;
    if (typeof date == "string") {
        var _date = new Date();
        if (/^\d{4}-\d{1,2}-\d{1,2}/.test(date)) {
            var year = parseInt(date.split("-")[0], 10);
            year = year < this.yearRange[0] ? this.yearRange[0] : year;
            year = year > this.yearRange[1] ? this.yearRange[1] : year;
            var month = parseInt(date.split("-")[1], 10);
            month = month < 1 ? 1 : month;
            month = month > 12 ? 12 : month;
            var day = parseInt(date.split("-")[2], 10);
            var month12 = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
            month12[1] = (year % 4 == 0 && year % 100 != 4) || year % 400 == 0 ? 29 : 28;
            day = day < 1 ? 1 : day;
            day = day > month12[month - 1] ? month12[month - 1] : day;
            _date.setFullYear(year, month - 1, day);
        } else if (/^\d{4}-\d{1,2}/.test(date)) {
            this.type = "month";
            var year = parseInt(date.split("-")[0], 10);
            year = year < this.yearRange[0] ? this.yearRange[0] : year;
            year = year > this.yearRange[1] ? this.yearRange[1] : year;
            var month = parseInt(date.split("-")[1], 10);
            month = month < 1 ? 1 : month;
            month = month > 12 ? 12 : month;
            _date.setFullYear(year, month - 1);
        } else if (/^\d{4}/.test(date)) {
            this.type = "year";
            var year = parseInt(date, 10);
            year = year < this.yearRange[0] ? this.yearRange[0] : year;
            year = year > this.yearRange[1] ? this.yearRange[1] : year;
            _date.setFullYear(year);
        }
        this.date.setFullYear(_date.getFullYear(), _date.getMonth(), _date.getDate());
        this.selectedDate.setFullYear(_date.getFullYear(), _date.getMonth(), _date.getDate());
    }
    this.obj = obj;
    if(this.obj){
        obj.css({background:"url() 3px center no-repeat",paddingLeft:"25px",width:(obj.width() - 22) +'px'});
        obj.attr("readonly","readonly");
    }
    this.id = null;
    this.width = 350;
    this.action = null;//选中后的动作
    this.finalDate = null;
    this.toString = function () {
        var rc = "";
        if (this.type == "year") { 
            this.finalDate = !!this.minDate && this.date < this.minDate ? this.minDate : this.date;
            this.finalDate = !!this.maxDate && this.date > this.maxDate ? this.maxDate : this.finalDate;
            this.finalDate = !!this.minDate && !!this.maxDate && this.minDate > this.maxDate ? this.date : this.finalDate;
            rc = this.finalDate.getFullYear();
        } else if (this.type == "month") {
            this.finalDate = !!this.minDate && this.date < this.minDate ? this.minDate : this.date;
            this.finalDate = !!this.maxDate && this.date > this.maxDate ? this.maxDate : this.finalDate;
            this.finalDate = !!this.minDate && !!this.maxDate && this.minDate > this.maxDate ? this.date : this.finalDate;
            var month = this.finalDate.getMonth() + 1;
            rc = this.finalDate.getFullYear() + "-" + (month < 10 ? "0" + month : month);
        } else {
            this.finalDate = !!this.minDate && this.selectedDate < this.minDate ? this.minDate : this.selectedDate;
            this.finalDate = !!this.maxDate && this.selectedDate > this.maxDate ? this.maxDate : this.finalDate;
            this.finalDate = !!this.minDate && !!this.maxDate && this.minDate > this.maxDate ? this.selectedDate : this.finalDate;
            var month = this.finalDate.getMonth() + 1;
            var date = this.finalDate.getDate();
            rc = this.finalDate.getFullYear() + "-" + (month < 10 ? "0" + month : month) + "-" + (date < 10 ? "0" + date : date);
            for(var i = 0; i < _this.timeType.length; i++){
                _this.timeType[i] = _this.timeType[i] > 9 ? parseInt(_this.timeType[i]) : "0" + parseInt(_this.timeType[i]);
            }
            if(this.type == "time"){
                rc = "";
            }else{
                rc += this.timeType.length > 0 ? " " : "";
            }
            if(this.timeType.length == 1){
                this.finalDate.setHours(this.timeType[0]);
                rc += this.timeType[0];
            }else if(this.timeType.length == 2){
                this.finalDate.setHours(this.timeType[0]);
                this.finalDate.setMinutes(this.timeType[1]);
                rc += this.timeType[0] + ":" + this.timeType[1];
            }else if(this.timeType.length == 3){
                this.finalDate.setHours(this.timeType[0]);
                this.finalDate.setMinutes(this.timeType[1]);
                this.finalDate.setSeconds(this.timeType[2]);
                rc += this.timeType[0] + ":" + this.timeType[1] + ":" + this.timeType[2];
            }
        }
        return rc;
    }
    if(date){
        if(this.obj) obj.val(date);
        if(this.timeType.length > 0) {
            if(this.type == 'time'){
                this.selectedDate.parse(date,'time');
                this.timeType = date.split(':');
            }else{
                this.selectedDate.parse(date,'date');
                this.timeType = date.split(' ')[1].split(':');
            }
        }else{
            this.selectedDate.parse(date,this.type == 'time' ? 'time' : 'date');
        }
        this.finalDate = this.selectedDate;
    }else{
        if(this.obj) obj.val(date == undefined ? this.toString() : "");
    }
    this.zIndex = a.zIndex(4);
    this.open = function (fn) {
        if(!a.Calendar.isShow){
            a.Calendar.isShow = true;
            this.id = "calendar" + new Date().only();
            var scrollTop = $(window).scrollTop();
            a.creatCover({id:this.id + "_cover",obj:window,zIndex:this.zIndex - 1,opacity:0,background:"#ffffff",position:"fixed",unScroll0:true});
            var boxStyles = this.obj ? this.boxStyles + "left:" + this.obj.offset().left + "px;top:" + (this.obj.offset().top + this.obj.height() + 5) + "px;" : this.boxStyles;
            var calendarBox = "<div id='" + this.id + "' class='unSelect boxShadow' style='border:1px solid #eee;border-radius :5px;width:" + (this.width + 20) + "px;position:absolute;z-index:" + this.zIndex + ";" + boxStyles + "text-align:center;background:#fff;min-height:200px;color:#333333'>";
            calendarBox += "</div>";
            $("body").append(calendarBox);
            $(window).scrollTop(scrollTop);
            this.show();
            $("#" + this.id + "_cover").click(function () {
                _this.close();
            });
            if (fn && typeof fn == "function") this.action = fn;
        }
    }
    this.show = function (type,noAnimate) {
        if (this.type == "year" && type != "year") type = "year";//年份日历
        if (this.type == "month" && type != "month" && type != "year") type = "month";//月份日历
        if(this.type == "time") type = "time";//时间
        var top = "", style = "<style>", center = "<div class='dateContent'><div id='dateContent'><div id='dateContentBox'>";
        var width = this.width / 7;
        var sliderWidth = 0;
        style += noAnimate ? "" : "@keyframes dateContent{from {transform:scale(0.5,0.5);} to {transform:scale(1,1);}}";
        style += ".dateContent{width: " + this.width + "px;height:" + this.width + "px;overflow: hidden;margin:0px 10px;animation: dateContent 0.5s;}";
        style += "#dateContent{width: " + (this.width + 20) + "px;height:" + (this.width + 20) + "px;overflow: scroll;}";
        style += ".dateTitle{text-align: right;height: 50px; line-height: 50px;overflow: hidden;margin-top:10px;}";
        style += ".dayTitle{text-align: center;height: " + width + "px; line-height: " + width + "px;overflow: hidden;width:" + width + "px;float:left;}";
        if (type == "year") {
            width = this.width / 5;
            style += ".dateSpan{cursor: pointer;width:" + width + "px;height:" + width + "px; text-align:center;line-height:" + width + "px;float:left;overflow: hidden;border-radius :" + width + "px}";
            top = "<div class='dateTitle'><span style='float: left; margin-left: 10px;color:#777777'>" + this.yearRange[0] + "-" + this.yearRange[1] + "</span><span style='margin-right: 10px; border:1px solid #d5d5d5; border-radius: 3px;padding:3px 5px; cursor: pointer;' id='clearBtn'>清空</span></div>";
            for (var i = this.yearRange[0]; i <= this.yearRange[1]; i++) {
                center += "<div class='" + (i == this.date.getFullYear() ? "dateSpan dateSpanActive" : "dateSpan") + " years'>" + i + "</div>";
            }
        } else if (type == "month") {
            width = this.width / 5;
            style += ".dateSpan{cursor: pointer;width:" + width + "px;height:" + width + "px; text-align:center;line-height:" + width + "px;float:left;overflow: hidden;border-radius :" + width + "px}";
            top = "<div class='dateTitle'><span style='float: left; margin-left: 10px;'><font id='inputYear' title='点击输入年份'>" + this.date.getFullYear() + " 年</font><font id='setYearBtn' style='font-size: 12px; cursor: pointer;color: #b0b0b0;margin-left: 5px;'>< 选择年份</font></span><span style='margin-right: 10px; border:1px solid #d5d5d5; border-radius: 3px;padding:3px 5px; cursor: pointer;' id='clearBtn'>清空</span></div>";
            for (var i = 1; i <= 12; i++) {
                center += "<div class='" + (i == this.date.getMonth() + 1 ? "dateSpan dateSpanActive" : "dateSpan") + " months'>" + i + "月</div>";
            }
        } else if(type == "time"){//设置时分秒
            top = this.type == "time" ? "<div class='dateTitle'><span style='margin-right: 10px; border:1px solid #d5d5d5; border-radius: 3px;padding:3px 5px; cursor: pointer;' id='clearBtn'>清空</span></div>" : "<div class='dateTitle'><span style='float: left; margin-left: 10px;cursor: pointer;' id='setDaysBtn'>" + this.date.getFullYear() + " 年 " + (this.date.getMonth() + 1) + " 月 " + this.selectedDate.getDate() + " 日<font style='font-size: 12px; color: #b0b0b0;margin-left: 5px;'>< 选择日期</font></span><span style='margin-right: 10px; border:1px solid #d5d5d5; border-radius: 3px;padding:3px 5px; cursor: pointer;' id='clearBtn'>清空</span></div>";
            var input = "<div class='timeInputs'>",slider = "<div class='timeSliders'>";
            for(var i = 0; i < this.timeType.length; i ++){
                switch(i){
                    case 0:
                        input += "<input type='text' class='timeInput' id='timeHoursInput' value='' />";
                        slider += "<div class='timeSlider' id='timeHoursSlider'><div class='timeSliderTitle'>小时</div><div class='timeSliderAction'><div class='timeSliderAction_active'></div><div class='timeSliderAction_block'></div></div><div class='timeSliderMax'>23</div></div>";
                        break;
                    case 1:
                        input += ":<input type='text' class='timeInput' id='timeMinutesInput' value='' />";
                        slider += "<div class='timeSlider' id='timeMinutesSlider'><div class='timeSliderTitle'>分钟</div><div class='timeSliderAction'><div class='timeSliderAction_active'></div><div class='timeSliderAction_block'></div></div><div class='timeSliderMax'>59</div></div>";
                        break;
                    case 2:
                        input += ":<input type='text' class='timeInput' id='timeSecondsInput' value='' />";
                        slider += "<div class='timeSlider' id='timeSecondsSlider'><div class='timeSliderTitle'>秒</div><div class='timeSliderAction'><div class='timeSliderAction_active'></div><div class='timeSliderAction_block'></div></div><div class='timeSliderMax'>59</div></div>";
                        break;
                    default:
                        break;
                }
            }
            input += "</div>";
            slider += "</div>";
            center += input + slider;
            center += "<div style='text-align:center;'><span style='border:1px solid #d5d5d5; border-radius: 3px;padding:5px 15px; cursor: pointer;' id='timeOk'>确定</span></div>";
            style += ".timeInputs{text-align:center;margin-top:40px;margin-bottom:20px;}";
            style += ".timeInput{width:30px;height:30px;padding:0px 5px;line-height:40px;margin:0px 5px;border:1px solid #dedede;text-align:center;}";
            style += ".timeSliders{margin-top:30px;margin-bottom:20px;}";
            style += ".timeSlider{margin:10px auto;width:" + (this.width - 80) + "px;height:50px;overflow:hidden;}";
            style += ".timeSliderTitle{float:left;width:50px;text-align:left;}";
            sliderWidth = this.width - 80 - 100;
            style += ".timeSliderAction{float:left;width:" + sliderWidth + "px;height:10px;border-radius:2px;background:#e9e9e9;margin-top:6px;}";
            style += ".timeSliderAction_active{height:10px;border-radius:2px;background:#00a7f5;overflow:hidden;width:0px;}";
            style += ".timeSliderAction_block{width:18px;height:18px;position:absolute;border-radius:2px;background:#1e8dc1;cursor:pointer;margin-top:-14px;}";
            style += ".timeSliderMax{float:left;width:50px;text-align:center;}";
        } else {
            style += ".dateSpan{cursor: pointer;width:" + width + "px;height:" + width + "px; text-align:center;line-height:" + width + "px;float:left;overflow: hidden;border-radius :" + width + "px}";
            top = "<div class='dateTitle'><span style='float: left; margin-left: 10px;'><font id='inputYear' title='点击输入年份'>" + this.date.getFullYear() + " 年</font><font id='inputMonth' title='点击输入月份'> " + (this.date.getMonth() + 1) + " 月</font><font id='setMonthBtn' style='font-size: 12px; cursor: pointer;color: #b0b0b0;margin-left: 5px;'>< 选择月份</font></span><span style='margin-right: 10px; border:1px solid #d5d5d5; border-radius: 3px;padding:3px 5px; cursor: pointer;' id='clearBtn'>清空</span><span id='todayBtn' style='margin-right: 20px; border:1px solid #d5d5d5; border-radius: 3px;padding:3px 5px; cursor: pointer;'>今日</span><span id='prevMonthBtn' style='margin-right: 20px;cursor: pointer;font-size: 20px;'><</span><span id='nextMonthBtn' style='margin-right: 20px;cursor: pointer;font-size: 20px;'>></span></div>";
            center += "<div><div class='dayTitle'>日</div><div class='dayTitle'>一</div><div class='dayTitle'>二</div><div class='dayTitle'>三</div><div class='dayTitle'>四</div><div class='dayTitle'>五</div><div class='dayTitle'>六</div><div style='clear:both'></div></div>";
            var _date = this.date;
            _date.setDate(1);
            for (var i = 0; i < _date.getDay(); i++) {
                center += "<div class='dateSpan dateSpanNo'> </div>";
            }
            var months = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
            months[1] = (this.date.getFullYear() % 4 == 0 && this.date.getFullYear() % 100 != 4) || this.date.getFullYear() % 400 == 0 ? 29 : 28;//闰年判断
            for (var i = 1; i <= months[this.date.getMonth()]; i++) {
                center += "<div class='" + (i == this.selectedDate.getDate() && this.selectedDate.getMonth() == this.date.getMonth() && this.selectedDate.getFullYear() == this.date.getFullYear() ? "dateSpan dateSpanActive" : "dateSpan") + " days'>" + i + "</div>";
            }
        }
        center += "<div style='clear:both;'></div>";
        center += "</div></div></div>";
        style += ".dateSpan:hover{background:#f4f4f4;}";
        style += ".dateSpanNo{cursor: default;}";
        style += ".dateSpanNo:hover{background:#fff;}";
        style += ".dateSpanActive{background:#00b7ee;color:#fff;}";
        style += ".dateSpanActive:hover{background:#328dd8;}";
        style += "</style>";
        $("#" + this.id).html(top + center + style);
        if (type == "year") {
            $("#dateContent").scrollTop(($("#dateContentBox").height() - $("#dateContent").height()) * ((this.date.getFullYear() - this.yearRange[0]) / (this.yearRange[1] - this.yearRange[0])));
        }
        $(".years").click(function () {
            _this.date.setFullYear($(this).html());
            _this.show("month",(_this.type == "year"));
            if (_this.type == "year" && _this.action) _this.action(_this.toString());
        });
        $(".months").click(function () {
            _this.date.setMonth($(this).html().replace("月", "") - 1);
            _this.show("",(_this.type == "month"));
            if (_this.type == "month" && _this.action) _this.action(_this.toString());
        });
        $(".days").click(function () {
            _this.selectedDate.setFullYear(_this.date.getFullYear(), _this.date.getMonth(), $(this).html());
            if(_this.timeType.length > 0){
                _this.show("time",false);//进行时分秒设置
            }else{
                _this.show("",true);
                if (_this.action) _this.action(_this.toString());
            }
        });
        $('#inputYear').click(function(){
            var year = _this.date.getFullYear();
            a.confirmx('<input type="text" id="inputData" style="border:1px solid #e4e4e4;padding:5px;" maxlength="4" value="' + year + '" /><div style="display:none;color:#ff0000;" id="inputDataErr">输入错误,必须为' + _this.yearRange[0] + '-' + _this.yearRange[1] + '之间的整数</div>',function(){
                var v = parseInt($('#inputData').val());
                _this.date.setFullYear(v);
                _this.selectedDate.setFullYear(v);
                $('#inputYear').html(v + ' 年');
            },{_h:170,title:'输入年份',verifyFn:function(){
                var v = parseInt($('#inputData').val());
                $('#inputDataErr').hide();
                if(v >= _this.yearRange[0] && v <= _this.yearRange[1]){
                    return true;
                }else{
                    $('#inputDataErr').show();
                }
            }});
        })
        $('#inputMonth').click(function(){
            var month = _this.date.getMonth() + 1;
            a.confirmx('<input type="text" id="inputData" style="border:1px solid #e4e4e4;padding:5px;" maxlength="2" value="' + month + '" /><div style="display:none;color:#ff0000;" id="inputDataErr">输入错误,必须为1-12之间的整数</div>',function(){
                var v = parseInt($('#inputData').val()) - 1;
                _this.date.setMonth(v);
                _this.selectedDate.setMonth(v);
                $('#inputMonth').html((v + 1) + ' 月');
            },{_h:170,title:'输入月份',verifyFn:function(){
                var v = parseInt($('#inputData').val()) - 1;
                $('#inputDataErr').hide();
                if(v >= 0 && v <= 11){
                    return true;
                }else{
                    $('#inputDataErr').show();
                }
            }});
        })
        $("#setMonthBtn").click(function () {
            _this.show("month");
        });
        $("#setYearBtn").click(function () {
            _this.show("year");
        });
        $("#setDaysBtn").click(function(){
            _this.show("");
        })
        $("#timeOk").click(function(){
            if (_this.action) _this.action(_this.toString());
        })
        $("#clearBtn").click(function(){
            if (_this.action) _this.action("");
        })
        $("#todayBtn").click(function () {
            var d = new Date();
            _this.date.setFullYear(d.getFullYear(), d.getMonth(), d.getDate());
            _this.selectedDate.setFullYear(d.getFullYear(), d.getMonth(), d.getDate());
            _this.show();
            if (_this.action) _this.action(_this.toString());
        });
        $("#prevMonthBtn").click(function () {
            var year = _this.date.getFullYear();
            var month = _this.date.getMonth();
            if (month == 0) {
                if (year == _this.yearRange[0]) {
                    a.log("不能超过最低年限");
                } else {
                    year--;
                    month = 11;
                }
            } else {
                month--;
            }
            _this.date.setFullYear(year, month);
            _this.show("",true);
        });
        $("#nextMonthBtn").click(function () {
            var year = _this.date.getFullYear();
            var month = _this.date.getMonth();
            if (month == 11) {
                if (year == _this.yearRange[1]) {
                    a.log("不能超过最高年限");
                } else {
                    year++;
                    month = 0;
                }
            } else {
                month++;
            }
            _this.date.setFullYear(year, month);
            _this.show("",true);
        });
        if(_this.timeType.length > 0){
            for(var i = 0; i < _this.timeType.length; i++){
                timeShow(i + 1);
                bindSlideFn(i + 1);
            }
        }
        function bindSlideFn(type){
            var max = 23;
            var inputId = "",sliderId = "";
            switch(type){
                case 1:
                    inputId = "timeHoursInput";
                    sliderId = "timeHoursSlider";
                    break;
                case 2:
                    max = 59;
                    inputId = "timeMinutesInput";
                    sliderId = "timeMinutesSlider";
                    break;
                case 3:
                    max = 59;
                    inputId = "timeSecondsInput";
                    sliderId = "timeSecondsSlider";
                    break;
                default:
                    break;
            }
            $("#" + inputId).keydown(function(){
                var _value = $(this).val();
                $(this).bind("keyup",function(){
                    var value = parseInt($(this).val() || 0);
                    if(/\d/.test(value) && value >= 0 && value <= max){
                        _this.timeType[type - 1] = value;
                    }else{
                        _this.timeType[type - 1] = _value;
                    }
                    timeShow(type);
                    $(this).unbind("keyup");
                })
            })
            $("#" + sliderId + " .timeSliderAction_block").mousedown(function(e){
                var _sliderWidth = $("#" + sliderId + " .timeSliderAction_active").width();
                var mouseX = e.clientX;
                $("body").addClass("unSelect");
                $(window).bind("mousemove",windowMove);
                $(window).bind("mouseup",unBindWindowMove);
                function windowMove(e){
                    var l = _sliderWidth + (e.clientX - mouseX);
                    l = l > sliderWidth ? sliderWidth : l;
                    l = l < 0 ? 0 : l;
                    var n = Math.ceil(l / sliderWidth * max);
                    _this.timeType[type - 1] = n;
                    timeShow(type);
                }
                function unBindWindowMove(e){
                    $("body").removeClass("unSelect");
                    $(window).unbind("mousemove",windowMove);
                    $(window).unbind("mouseup",unBindWindowMove);
                }
            })
        }
        function timeShow(type){
            _this.timeType[type - 1] = _this.timeType[type - 1] > 9 ? parseInt(_this.timeType[type - 1]) : "0" + parseInt(_this.timeType[type - 1]);
            var _sliderWidth = 0;
            var inputId = "",sliderId = "";
            switch(type){
                case 1:
                    _sliderWidth = _this.timeType[0] / 24 * sliderWidth;
                    inputId = "timeHoursInput";
                    sliderId = "timeHoursSlider";
                    break;
                case 2:
                    _sliderWidth = _this.timeType[1] / 60 * sliderWidth;
                    inputId = "timeMinutesInput";
                    sliderId = "timeMinutesSlider";
                    break;
                case 3:
                    _sliderWidth = _this.timeType[2] / 60 * sliderWidth;
                    inputId = "timeSecondsInput";
                    sliderId = "timeSecondsSlider";
                    break;
                default:
                    break;
            }
            $("#" + inputId).val(_this.timeType[type - 1]);
            $("#" + sliderId + " .timeSliderAction_active").width(_sliderWidth);
            $("#" + sliderId + " .timeSliderAction_block").css("margin-left",_sliderWidth - 9 + "px");
        }
    }
    this.close = function () {
        a.Calendar.isShow = false;
        $("#" + this.id + "_cover").remove();
        $("#" + this.id).remove();
    }
}
a.Calendar.isShow = false;//只能显示一个日历
//Calendar end
//Area begin
a.Area1 = function(args){
    var obj = args.obj,type = args.type || 3,lineNum = args.lineNum;
    var _this = this;
    this.id = (new Date()).only();
    this.load = function(){
        var script = document.createElement('script'); 
        script.type = 'text/javascript';
        script.src = "js/AreaData.js";
        document.body.appendChild(script);
        script.onload = function(){}
    }
    if(!window.AreaData) this.load();
    this.flog = 0; //1:选择省 2:选择市 3:选择区
    this.province = null;//省
    this.town = null;//市
    this.district = null;//区
    this.value = "";
    this.setData = function(id){
        var spanString = "<span style='padding:3px 15px;border:1px solid #e4e4e4;margin-left:10px;cursor:pointer;'>" + (this.province ? AreaData[this.province][0] : "选择省") + "</span>";
        if(this.flog == 3){
            spanString += "<span style='padding:3px 15px;border:1px solid #e4e4e4;margin-left:10px;cursor:pointer;'>" + (this.town ? AreaData[this.town][0] : "选择市") + "</span>";
            spanString += "<span style='padding:3px 15px;border:1px solid #e4e4e4;margin-left:10px;cursor:pointer;'>" + (this.district ? AreaData[this.district][0] : "选择区") + "</span>";
        }else if(this.flog == 2){
            spanString += "<span style='padding:3px 15px;border:1px solid #e4e4e4;margin-left:10px;cursor:pointer;'>" + (this.town ? AreaData[this.town][0] : "选择市") + "</span>";
        }
        $("#areaSpan" + this.id).find("div").html(spanString);
        $("#areaSpan" + this.id).find("span").eq(_this.flog - 1).css({background:"#00b7ee",color:"#fff"});
        $("#areaSpan" + this.id).find("span").eq(0).click(function(){
            _this.town = null;//市
            _this.district = null;//区
            _this.flog = 1;
            _this.setData(1);
        })
        $("#areaSpan" + this.id).find("span").eq(1).click(function(){
            _this.district = null;//区
            _this.flog = 2;
            _this.setData(_this.town);
        })
        var dataString = "";
        for(var k in AreaData){
            if(AreaData[k][1] == id){
                dataString += "<div style='width:100px;line-height:30px;height:30px;overflow:hidden;border:1px solid #fff;overflow:hidden;float:left;cursor:pointer;' vaule='" + k + "' title='" + AreaData[k][0] + "'>" + AreaData[k][0] + "</div>"
            }
        }
        dataString += "<div class='clear'></div>";
        $("#areaContent" + this.id).html(dataString);
        $("#areaContent" + this.id).find("div").each(function(i){
            $(this).mouseover(function(){
                $(this).css("color","#ff0000");
            })
            $(this).mouseout(function(){
                $(this).css("color","#666");
            })
            $(this).click(function(){
                var k = $(this).attr("vaule");
                switch(_this.flog){
                    case 1:
                        _this.province = k;
                        if(type >= 2){
                            _this.flog ++;
                            _this.town = null;
                            _this.district = null;
                            _this.setData(k);
                        }else{
                            _this.toString();
                        }
                        break;
                    case 2:
                        _this.town = k;
                        if(type >= 3){
                            _this.flog ++;
                            _this.district = null;
                            _this.setData(k);
                        }else{
                            _this.toString();
                        }
                        break;
                    case 3:
                        _this.district = k;
                        _this.toString();
                        break;
                }
            })
        })
    }
    this.val = function(s){
        if(s){
            obj.val(s);
        }else{
            return obj.val();
        }
    }
    this.toString = function(){
        var areaString = "";
        if(this.province) areaString += AreaData[this.province][0];
        if(this.town) areaString += AreaData[this.town][0];
        if(this.district) areaString += AreaData[this.district][0];
        obj.val(areaString);
        this.close();
    }
    lineNum = !lineNum || lineNum < 4 ? 4 : lineNum;
    this.width = lineNum * 100 + 40;
    this.height = 200;
    this.open = function(s){
        a.creatCover({id:this.id + "_cover",obj:window,zIndex:a.zIndex(4),opacity:0,background:"#ffffff",position:"fixed",unScroll0:true});
        var box = "<div id='areaBox" + this.id + "' style='border:1px solid #ccc;overflow:hidden;width:" + this.width + "px;background:#fff;position:absolute;left:" + obj.offset().left + "px;top:" + (obj.offset().top + obj.height()) + "px;z-index:" + a.zIndex(4) + ";'>";
        box += "<div id='areaSpan" + this.id + "' style='border-bottom:1px solid #e4e4e4;line-height:40px;overflow:hidden;height:40px;text-align:right;'><div style='float:left;'>";
        box += "</div><font style='padding:2px 7px; border:1px solid #e4e4e4;cursor:pointer;margin-right:10px;' id='reset" + this.id + "'>清空</font><span id='close" + this.id + "' style='margin-right:10px;cursor:pointer;'>X</span></div>";
        box += "<div id='areaContent" + this.id + "' style='overflow:auto;height:" + (this.height - 40) + "px;margin-left:10px;padding-top:10px;padding-bottom:10px;'></div>";
        box += "</div>";
        $("body").append(box);
        $("#close" + this.id + ",#" + this.id + "_cover").click(function(){
            _this.close();
        });
        $("#reset" + this.id).click(function(){
            _this.close();
            _this.toString();
        })
        this.flog = !this.district ? (!this.town ? 1 : 2) : 3;
        var id = !this.district ? (this.province ? this.province : 1) : this.town;
        this.setData(id.toString());
    }
    this.close = function(){
        $("#" + this.id + "_cover").remove();
        $("#areaBox" + this.id).remove();
        obj.prev(".data_error").hide();
        _this.province = undefined;
        _this.town = undefined;
        _this.district = undefined;
    }
    obj.focus(function(){
        obj.prev(".data_error").hide();
        _this.close();
        _this.open(this.value);
    })
}
//Area end
//Radio begin
a.Radio = function (arr,args) {
    args = args || {};
    this.objs = arr;
    this.activeObj = null;
    var _this = this;
    this.changeFn = args.changeFn || '';
    var readonly = false;
    this.setReadOnly = function(b){
        readonly = b;
        this.objs.each(function () {
            $(this).attr('readonly','readonly');
        });
    }
    this.objs.click(function () {
        if(readonly) return false;
        _this.activeObj = $(this)[0];
        _this.show();
    });
    this.show = function () {
        this.objs.each(function () {
            $(this)[0].checked = _this.activeObj && _this.activeObj.value == $(this)[0].value ? true : false;
        });
        if(this.changeFn) this.changeFn(this.val());
    }
    this.val = function (s) {
        if (s == undefined) {
            return this.activeObj ? $(this.activeObj).val() : '';
        } else {
            this.objs.each(function () {
                if ($(this).val() == s) {
                    _this.activeObj = $(this)[0];
                    _this.show();
                }
            });
        }
    }
    this.objs.each(function () {
        if($(this)[0].checked) _this.activeObj = $(this)[0];
    });
    this.show();
}
//Radio end
//Checkbox begin
a.Checkbox = function(arr,isArrType){
    var readonly = false;
    this.setReadOnly = function(b){
        readonly = b;
        for(var i = 0; i < arr.length; i++) arr[i].attr('readonly','readonly');
    }
    this.val = function(s){
        if(s == undefined){
            var rc = [];
            for(var i = 0; i < arr.length; i++){
                if(arr[i].checked) rc.push(arr[i].value);
            }
            return !isArrType ? rc.join(",") : rc;
        }else{
            var sArr = !isArrType ? s.split(",") : s;
            for(var i = 0; i < sArr.length; i++){
                for(var j = 0; j < arr.length; j++){
                    if(arr[j].value == sArr[i]){
                        arr[j].checked = true;
                    }
                }
            }
        }
    }
}
//Checkbox end
//download begin
a.download = function (url,args) {
    args = args || {};
    var meth = args.meth ? args.meth : "";
    var endTime = args.endTime ? args.endTime : 10000;
    var endFn = args.endFn ? args.endFn : "";
    if(meth == "iframe"){
        var id = "downIframe" + new Date().only();
        $("body").append("<iframe class='downIframe' id='" + id + "' style='display: none;' src='" + url + "'></iframe>");
        setTimeout(function () {
            $("#" + id).remove();
            if(endFn) endFn(id);
        }, endTime)
    }else{
        window.open(url, "_blank");
        if(endFn) endFn();
    }
}
//download end
//Windows begin
a.Windows = function (args) {
    args = args || {};
    this.id = "Windows" + new Date().only();
    this.width = args.width || 500;
    this.height = args.height || 300;
    this.title = args.title || "新建弹窗";//窗口标题
    this.content = args.content || "";//内容
    this.bottom = args.bottom || "";
    this.closeBtn = args.closeBtn == false ? false : true;
    this.cover = args.cover == false ? false : true;
    this.coverArgs = args.coverArgs || {};
    this.coverClose = args.coverClose || false;
    this.cancleFn = args.cancleFn || '';//取消后执行
    this.style = args.style || "";
    this.styles = args.styles || {};
    this.drag = args.drag == false ? false : true;
    this.titleHeight = args.titleHeight >= 0 ? args.titleHeight : 30;
    this.bottomHeight = args.bottomHeight >= 0 ? args.bottomHeight : 40;
    var _this = this;
    this.open = function () {
        if(this.width > $(window).width()) this.width = $(window).width();
        if(this.height > $(window).height()) this.height = $(window).height();
        var windowScrollTop = $(window).scrollTop();
        if(this.cover) a.creatCover({id:this.id + "_cover",obj:window,zIndex:a.zIndex(4),opacity:this.coverArgs.opacity == undefined ? 0.5 : this.coverArgs.opacity,background:this.coverArgs.background || "#000000",position:"fixed"});
        var top = "<div id='" + this.id + "_top'><b id='" + this.id + "_top_title'>" + this.title + "</b>" + (this.closeBtn ? "<span id='" + this.id + "_close'>X</span>" : "") + "</div>";
        var center = "<div id='" + this.id + "_center'><div id='" + this.id + "_content'>" + this.content + "</div></div>";
        var bottom = this.bottom ? "<div id='" + this.id + "_bottom'>" + this.bottom + "</div>" : "";
        var style = "<style>";
        style += "#" + this.id + "{border:1px solid #e4e4e4;border-radius:3px;width:" + this.width + "px;background:#fff;position: fixed;z-index:" + a.zIndex(4) + "; left:" + ($(window).width() - this.width) / 2 + "px;top:" + ($(window).height() - this.height) / 2 + "px;" + (this.styles && this.styles.box ? this.styles.box : "") + "}";
        style += "#" + this.id + "_top{overflow:hidden;height:" + this.titleHeight + "px; text-align: right;line-height: " + this.titleHeight + "px; background:#f9f9f9;" + (this.styles && this.styles.top ? this.styles.top : "") + "}";
        style += "#" + this.id + "_top_title{float: left;margin-left:10px;" + (this.styles && this.styles.top_title ? this.styles.top_title : "") + "}";
        style += "#" + this.id + "_close{margin-right: 10px;cursor: pointer; font-family: Arial;" + (this.styles && this.styles.close ? this.styles.close : "") + "}";
        style += "#" + this.id + "_center{border-top:1px solid #e4e4e4;" + (this.styles && this.styles.center ? this.styles.center : "") + "}";
        style += "#" + this.id + "_content{height:" + (this.height - this.titleHeight - this.bottomHeight - 12) + "px;overflow:auto;" + (this.styles && this.styles.content ? this.styles.content : "") + "}";
        style += "#" + this.id + "_bottom{border-top:1px dashed #e4e4e4;height:" + this.bottomHeight + "px;overflow: hidden;" + (this.styles && this.styles.bottom ? this.styles.bottom : "") + "}";
        style += this.style ? this.style.replaceAll("{this_id}",this.id) : "";
        style += "</style>";
        $("body").append("<div class='boxShadow' id='" + this.id + "'>" + top + center + bottom + style + "</div>");
        $(window).scrollTop(windowScrollTop);
        if(this.bodyScrollNo) {
            $("body").attr("scroll","no");
            $("body").css("overflow","hidden");
        }
        $("#" + this.id + "_close").click(function () {
            _this.close();
        })
        if(this.coverClose){
            $("#" + this.id + "_cover").click(function(){
                _this.close();
            })
        }
        if(this.drag) a.Drag({obj:$("#" + this.id + "_top"),target:$("#" + this.id)});//绑定移动操作
    }
    this.close = function (msg) {
        if(this.cancleFn) this.cancleFn(msg);
        $("#" + this.id).remove();
        $("#" + this.id + "_cover").remove();
        if(this.bodyScrollNo) {
            $("body").removeAttr("scroll");
            $("body").css("overflow","visible");
        }
    }
}
//Windows end
//Drag begin
a.Drag = function(args){
    args = args || {};
    var obj = args.obj,target = args.target;
    obj.css({cursor:"move"});
    var left = 0, top = 0,_left = 0,_top = 0,w = $(window).width(), h = $(window).height(),_w = target.width(), _h = target.height();
    obj.bind("mousedown",windowBindMove);
    function windowBindMove(e){
        left = e.clientX,top = e.clientY,_left = target.offset().left,_top = target.offset().top;
        $("body").addClass("unSelect");
        $(window).bind("mousemove",windowMove);
        $(window).bind("mouseup",unBindWindowMove);
    }
    function windowMove(e){
        var l = _left + (e.clientX - left);
        var t = _top + (e.clientY - top);
        l = l < 0 ? 0 : (l > w - _w ? w - _w : l);
        t = t < 0 ? 0 : (t > h - _h ? h - _h : t);
        target.css({left:l + "px",top:t + "px"});
    }
    function unBindWindowMove(e){
        $("body").removeClass("unSelect");
        $(window).unbind("mousemove",windowMove);
        $(window).unbind("mouseup",unBindWindowMove);
    }
}
//Drag end
//MouseOverShow begin
a.MouseOverShow = function(mouseoverObj,showObj,args){
    args = args || {};
    var _this = this;
    var id = new Date().only();
    mouseoverObj.mouseover(function(){
        if(_this.timer) {
            clearTimeout(_this.timer);
        }else{
            if(args.string) {
                var top = mouseoverObj.offset().top + mouseoverObj.height() + 8;
                var left = mouseoverObj.offset().left;
                var style = 'position:absolute;left:' + left + 'px;top:' + top + 'px;border-radius:5px;width:180px;padding:16px 0px 16px 16px;background:#000;color:#fff;line-height:24px;background:#000;color:#fff;z-index:' + a.zIndex(4);
                showObj = '<div class="mouseOverShow" id="mouseOverShow' + id + '" style="' + style + (args.style || '') + '">' + args.string + '</div>';
                $('body').append(showObj);
                if(args.init) args.init(id);
                showObj = $('#mouseOverShow' + id);
                if(showObj.height() + top > $(window).height()) showObj.css({top:'auto',bottom:'0px'});
                if(showObj.width() + left > $(window).width()) showObj.css({left:'auto',right:'0px'});
                showObjBind();
            }else{
                showObj.show();
            }
        }
    })
    mouseoverObj.mouseout(function(){
        _this.timer = setTimeout(function(){
            if(args.string) {
                showObj.remove();
                showObj = '';
            }else{
                showObj.hide();
            }
            _this.timer = '';
        },300)
    })
    if(showObj) showObjBind();
    function showObjBind(){
        showObj.mouseover(function(){
            clearTimeout(_this.timer);
        })
        showObj.mouseout(function(){
            _this.timer = setTimeout(function(){
                if(args.string) {
                    showObj.remove();
                    showObj = '';
                }else{
                    showObj.hide();
                }
                _this.timer = '';
            },300)
        })
    }
}
//MouseOverShow end
//ColorPicker begin
a.ColorPicker = function(obj,fn,args){
    args = args || {};
    var _this = this;
    this.id = new Date().only();
    this.colors = args.colors || ['#ff3333','#ff33cc','#3333ff','#339933','#cccc33','#ff9933','#000000','#333333','#666666','#999999','#cccccc','#ffffff'];
    var html = '';
    for(var i = 0; i < this.colors.length; i ++) html += '<div class="pickerColors" title="'+ this.colors[i] +'" style="border:1px solid #fff;margin:0px 8px 8px 0px;width:18px;height:18px;float:left;background-color:' + this.colors[i] + '"></div>';
        var clearSpan = args.clear || '<span id="clear' + this.id + '" style="cursor:pointer;margin-right:16px;font-size:12px;">清空</span>'
        var picker = new a.MouseOverShow(obj,'',{string:'<div style="max-width:180px;" id="colorpicker' + this.id + '">' + html + '<div style="clear:both;"></div><div style="text-align:right;">' + clearSpan + '</div></div>',init:function(id){
        $('#colorpicker' + _this.id).find('.pickerColors').each(function(i){
            $(this).click(function(){
                fn(_this.colors[i]);
            })
        })
        $('#clear' + _this.id).click(function(){
            fn('');
        })
    },style:args.style + ';padding-bottom:8px;'});
}
//ColorPicker end
//JSONP begin
a.JSONP = function(url,fn){
    var id = new Date().only();
    window['JSONP' + id] = function(ret){
        try{ret = JSON.parse(ret);}catch(e){}
        fn(ret);
        $('#JSONP' + id).remove();
        window['JSONP' + id] = null;
    }
    url += (url.indexOf('?') > -1 ? '&' : '?') + 'callback=JSONP' + id;
    $('body').append('<div id="JSONP' + id + '"><script type="text/javascript" src="' + url + '"></script></div>');
}
//JSONP end
//Imgedit begin
//图片编辑
a.Imgedit = function(width,height,scale,radius,editType){
    var _this = this;
    this.title = "图片编辑器";
    this.data = "";
    this.dataBlob = "";
    this.width = width;
    this.height = height;
    this.maxHeight = $(window).height() - 270;
    this.radius = radius || 0;
    this.scale = scale;
    this.img = "";
    this.imgString = "";
    this.imgSize = [];//原图数据 长度3 0:宽，1:高，2:压缩比
    this.imgMove = [0,0];//图片移动量
    this.compress = 0.92;//质量压缩比例
    this.canvas = "";
    this.canvasObj = "";
    this.canvasImg = "";
    this.canvasImgObj = "";
    this.mimeType = "jpeg";
    this.loading = new a.loading({opacity:0});
    this.show = function(){
        if(this.img){
            var w = this.imgSize[0] * this.imgSize[2] / 100,h = this.imgSize[1] * this.imgSize[2] / 100;
            //清空画布
            this.canvasObj.width = 1000;
            this.canvasImgObj.width = this.width;
            this.canvasImgObj.height = this.height;
            if("|jpg|jpeg|bmp|".indexOf(this.mimeType) > -1){//不透明添加白色背景
                this.canvasImg.fillStyle = "#ffffff";
                this.canvasImg.fillRect(0,0,this.width,this.height);
            }
            //逆时针描点图形
            //左上
            var site = [[this.radius,0],[0,0],[0,this.radius]];
            this.canvasImg.moveTo(site[0][0],site[0][1]);
            this.canvasImg.arcTo(site[1][0],site[1][1],site[2][0],site[2][1],this.radius);
            //左下
            site = [[0,this.height - this.radius],[0,this.height],[this.radius,this.height]];
            this.canvasImg.lineTo(site[0][0],site[0][1]);
            this.canvasImg.arcTo(site[1][0],site[1][1],site[2][0], site[2][1],this.radius);
            //右下
            site = [[this.width - this.radius,this.height],[this.width,this.height],[this.width,this.height - this.radius]];
            this.canvasImg.lineTo(site[0][0],site[0][1]);
            this.canvasImg.arcTo(site[1][0],site[1][1],site[2][0], site[2][1],this.radius);
            //右上
            site = [[this.width,this.radius],[this.width,0],[this.width - this.radius,0]];
            this.canvasImg.lineTo(site[0][0],site[0][1]);
            this.canvasImg.arcTo(site[1][0],site[1][1],site[2][0], site[2][1],this.radius);
            this.canvasImg.closePath();
            this.canvasImg.clip();
            this.canvasImg.drawImage(this.img,(this.width - w) / 2 + this.imgMove[0],(this.height - h) / 2 + this.imgMove[1],w,h);
            //顺时针画遮罩
            this.canvas.moveTo(0,0);
            this.canvas.lineTo(1000,0);
            this.canvas.lineTo(1000,this.maxHeight);
            this.canvas.lineTo(0,this.maxHeight);
            this.canvas.closePath();
            var s = a.setImgSize({_w:1000,_h:this.maxHeight,w:this.width,h:this.height});
            this.canvas.moveTo(s[3],s[2]);
            this.canvas.lineTo(s[3],s[2] + s[1]);
            this.canvas.lineTo(s[3] + s[0],s[2] + s[1]);
            this.canvas.lineTo(s[3] + s[0],s[2]);
            this.canvas.closePath();
            this.canvas.fillStyle = "rgba(0,0,0,1)";
            this.canvas.fill();
            this.canvas.drawImage(this.canvasImgObj,s[3],s[2],s[0],s[1]);
            //转换
            this.data = this.canvasImgObj.toDataURL("image/" + this.mimeType,this.compress);
            this.dataBlob = a.dataURLtoBlob(this.data);
            var size = a.fileSize(this.dataBlob.size);
            var sizeTips = this.maxSize && this.maxSize < this.dataBlob.size ? "<font style='color:#ff0000;margin-left:5px;'>过大</font>" : "";
            $("#compress_slipText").html("(" + a.fileSize(this.dataBlob.size) + sizeTips + ")");
            $("#imgEditBoxImg").attr("title",this.width + "*" + this.height + "  " + size);
        }
    }
    this.prevView = function(fn){
        var img = new Image();
        img.onload = function(){
            var s = a.setImgSize({_w:1000,_h:_this.maxHeight,w:_this.width,h:_this.height});
            _this.canvas.drawImage(img,s[3],s[2],s[0],s[1]);
        }
        img.src = this.data;
    }
    this.Slip = function(moveObj,clickObj,showObj,fn,mouseUpFn,scale){
        var _this = this;
        var left = 0,w = clickObj.width(),p = 100,_p = p,v = w / p;
        moveObj.bind("mousedown",windowBindMove);
        function windowBindMove(e){
            _p = p;
            left = e.clientX;
            $("body").addClass("unSelect");
            $(window).bind("mousemove",windowMove);
            $(window).bind("mouseup",unBindWindowMove);
        }
        function windowMove(e){
            var l = e.clientX - left;
            p = Math.ceil(l / v) + _p;
            p = p > 100 ? 100 : p;
            p = p < 0 ? 0 : p;
            _this.set();
        }
        function unBindWindowMove(e){
            $("body").removeClass("unSelect");
            $(window).unbind("mousemove",windowMove);
            $(window).unbind("mouseup",unBindWindowMove);
            _this.set();
            if(mouseUpFn) mouseUpFn();
        }
        this.set = function(n){
            p = !n ? p : n;
            var _p = p;
            if(typeof scale == 'function') _p = scale(_p);
            moveObj.css("margin-left",p + "%");
            showObj.html(_p + "%");
            fn(_p);
        }
    }
    this.imgSlip = "";
    this.compressSlip = "";
    this.editType = {scale:true,width:true,height:true,radius:true,imgSlip:true,compressSlip:true,mimeType:true,recom:true};//编辑性数组
    if(editType){
        for(var key in editType){
            this.editType[key] = editType[key];
        }
    }
    this.open = function(file,fn,files){
        if(_this.loading.open) _this.loading.open();
        _this.imgString = a.getBlobURL(file);
        this.yuantu = false;
        _this.img = new Image();
        _this.img.onload = function(){
            if(_this.loading.close) _this.loading.close();
            if(!scale){
                 _this.editType.scale = false;
                 if(width && _this.editType.width && height && _this.editType.height){
                    _this.editType.width = false;
                    _this.editType.height = false;
                 }
            }
            _this.img = this;
            var availWidth = 1920;//最大宽度
            availWidth = this.width > availWidth ? availWidth : this.width;
            width = width || availWidth;
            _this.width = width;
            var setImgSize = a.setImgSize({
                w:this.width,
                h:this.height,
                _w:_this.width,
                _h:_this.height
            })
            //var p = _this.imgSize[0] <= width ? 50 : width / _this.imgSize[0] * 50;
            var p = setImgSize[0] / this.width * 50;
            _this.imgSize = [this.width,this.height,this.width < width ? 100  : p];
            height = height || parseInt(this.height * p / 100);
            _this.height = height;
            _this.radius = radius || 0;
            _this.radius = _this.radius >= _this.width / 2 || _this.radius >= _this.height / 2 ? Math.min(_this.width,_this.height) / 2 : _this.radius;
            _this.canvasObj = document.createElement("canvas");
            _this.canvasObj.width = this.width;
            _this.canvasObj.height = _this.maxHeight;
            _this.canvasImgObj = document.createElement("canvas");
            _this.canvasImgObj.width = _this.width;
            _this.canvasImgObj.height = _this.height;
            _this.canvas = _this.canvasObj.getContext("2d");
            _this.canvasImg = _this.canvasImgObj.getContext("2d");
            _this.html = "<div class='imgEditBox'>";
            _this.html += "<div class='imgEditBoxImg' id='imgEditBoxImg'></div>";
            _this.html += "<div class='imgEditBoxEdit'>";
            _this.html += "<div class='imgEditBoxEdit_size'>";
            var scaleHtml = !_this.editType.scale ? "" : "<font style='color:#3ec0ef;'>(比例 " + scale[0] + ":" + scale[1] + ")</font>";
            scaleHtml = !_this.editType.scale ? "" : "<input type='checkbox' checked" + (!_this.editType.scale ? " disabled='true'" : "") + " id='imgEditCheck' />固定比例" + scaleHtml;
            _this.html += "<div class='imgEditBoxEdit_size_check'>" + scaleHtml + "</div>";
            _this.html += "<div class='imgEditBoxEdit_size_css'>宽度(px):<input type='text'" + (!_this.editType.width ? " disabled='true'" : "") + " id='imgEditSetWidth' value='" + width + "' />" + (!_this.editType.width ? "" : "<font style='color:#c4c4c4;font-size:12px;'>最大" + width + "</font>") + "</div>";
            _this.html += "<div class='imgEditBoxEdit_size_css'>高度(px):<input type='text'" + (!_this.editType.height ? " disabled='true'" : "") + " id='imgEditSetHeight' value='" + _this.height + "' />" + (!_this.editType.height ? "" : "<font style='color:#c4c4c4;font-size:12px;'>最大" + _this.height + "</font>") + "</div>";
            _this.html += "<div class='imgEditBoxEdit_size_css'>圆角(px):<input type='text'" + (!_this.editType.radius ? " disabled='true'" : "") + " id='imgEditSetRadius' value='" + (!_this.radius ? 0 : _this.radius) + "' /></div>";
            _this.html += "</div>";
            _this.html += "<div class='imgEditBoxEdit_scale'>";
            //压缩
            _this.html += "<div class='imgEditBoxEdit_slipBox'>";
            _this.html += "<div class='imgEditBoxEdit_slipBox_name'>原图缩放:</div>";
            _this.html += "<div class='imgEditBoxEdit_slipBox_slip'><div class='imgEditBoxEdit_slipBox_slip_bg' id='img_slipClick'><div class='imgEditBoxEdit_slipBox_slip_n' id='img_slipMove'><div class='imgEditBoxEdit_slipBox_slip_n_t'><font id='img_slipPre' style='color:#3ec0ef;'>100%</font><font style='color:#ECECEC;font-size:12px;' id='img_slipText'>(1500*1200)</font></div><div class='imgEditBoxEdit_slipBox_slip_n_c'></div></div></div><div class='imgEditBoxEdit_slipBox_slip_p'><div style='width:20px;float:left;overflow:hidden;'>0%</div><div style='text-align:right;width:320px;float:right;'><div style='width:270px;float:left;text-align:center;'><span style='margin-left:25px;'>100%</span></div><div style='width:50px;float:right;text-align:right;overflow:hidden;'>1000%</div></div></div></div>";
            _this.html += "<div class='clear'></div>";
            _this.html += "</div>";
            //质量
            _this.html += "<div class='imgEditBoxEdit_slipBox'>";
            _this.html += "<div class='imgEditBoxEdit_slipBox_name'>质　　量:</div>";
            _this.html += "<div class='imgEditBoxEdit_slipBox_slip'><div class='imgEditBoxEdit_slipBox_slip_bg' id='compress_slipClick'><div class='imgEditBoxEdit_slipBox_slip_n' id='compress_slipMove'><div class='imgEditBoxEdit_slipBox_slip_n_t'><font id='compress_slipPre' style='color:#3ec0ef;'>100%</font><font style='color:#cbcaca;font-size:12px;' id='compress_slipText'>(质量越高,图片越大)</font></div><div class='imgEditBoxEdit_slipBox_slip_n_c'></div></div></div><div class='imgEditBoxEdit_slipBox_slip_p'><div style='width:20px;float:left;overflow:hidden;'>0%</div><div style='text-align:right;width:320px;float:right;'><div style='width:270px;float:left;text-align:center;'><span style='margin-left:25px;'>50%</span></div><div style='width:50px;float:right;text-align:right;overflow:hidden;'>100%</div></div></div></div>";
            _this.html += "<div class='clear'></div>";
            _this.html += "</div>";
            _this.html += "</div>";
            _this.html += "<div class='imgEditBoxEdit_recom'><div id='imgEditRecom'>推荐<br />设置</div></div>";
            _this.html += "<div class='clear'></div>";
            _this.html += "</div>";
            _this.html += "<div style='position:absolute;margin-left:45px;'><input type='checkbox' id='checkMimeType' />背景透明<span style='font-size:12px;color:#c4c4c4;'>-说明:设置为背景透明图片保存为PNG格式质量高占用空间大，不透明保存为JPEG格式，质量可调节</span><font style='color:#ff0000;margin-left:70px;'>使用原图</font><input type='checkbox' id='yuantu' /></div>";
            _this.html += "<style>";
            _this.html += ".unSelect{-webkit-user-select:none;-moz-user-select:none;-o-user-select:none;user-select:none;}";
            _this.html += ".imgEditBox{line-height:40px;}";
            _this.html += ".imgEditBoxImg{background:#fff;height:" + _this.maxHeight + "px;overflow:hidden;cursor:move;}";
            _this.html += ".imgEditBoxEdit{text-align:left;height:180px;overflow:hidden;}";
            _this.html += ".imgEditBoxEdit_size{width:300px;float:left;}";
            _this.html += ".imgEditBoxEdit_scale{width:470px;float:left;margin-top:20px;}";
            _this.html += ".imgEditBoxEdit_recom{width:150px;float:left;margin-left:30px;}";
            _this.html += ".imgEditBoxEdit_size_check{margin-left:110px;margin-top:10px;height:40px;}";
            _this.html += ".imgEditBoxEdit_size_css{margin-left:50px;}";
            _this.html += ".imgEditBoxEdit_size_css input{ width:100px;height:30px;line-height:30px;padding:0px 5px;margin:0px 5px;border:1px solid #dcdcdc;}";
            _this.html += ".imgEditBoxEdit_size_css input:hover{border-color:#3ec0ef;}";
            _this.html += "#imgEditRecom{width:123px;padding:35px 0px;border-radius:5px;line-height:20px;text-align:center;border:1px solid #eae9e9;margin-top:45px;cursor:pointer;background:#fdfdfd;}";
            _this.html += "#imgEditRecom:hover{background:#fff;}";
            _this.html += ".imgEditBoxEdit_slipBox{height:70px;margin-top:10px;}";
            _this.html += ".imgEditBoxEdit_slipBox_name{width:70px;float:left;line-height:70px;}";
            _this.html += ".imgEditBoxEdit_slipBox_slip{width:320px;float:left;font-family:Arial;}";
            _this.html += ".imgEditBoxEdit_slipBox_slip_n{margin-left:100%;}";
            _this.html += ".imgEditBoxEdit_slipBox_slip_n_t{line-height:16px;position:absolute;margin-top:-18px;}";
            _this.html += ".imgEditBoxEdit_slipBox_slip_n_c{width:12px;height:24px;background:#3ec0ef;cursor:pointer;}";
            _this.html += ".imgEditBoxEdit_slipBox_slip_bg{background:url('') left 7px repeat-x;margin-top:23px;}";
            _this.html += ".imgEditBoxEdit_slipBox_slip_p{line-height:20px;width:340px;font-size:12px;}";
            _this.html += "</style>";
            _this.html += "</div>";
            a.confirmx(_this.html,function(){
                fn(_this.yuantu === false ? _this.data : false);
            },{title:_this.title,_w:1000,_h:_this.maxHeight + 262,bodyScrollNo:true,initFn:function(){
                //是否固定比例
                var changeType = 0;
                $('#yuantu').change(function(){
                    _this.yuantu = this.checked;
                })
                $("#imgEditCheck").change(function(){
                    if(!_this.editType.scale) return false;
                    if(!this.checked){
                        _this.scale = "";
                    }else{
                        _this.scale = scale;
                        if(changeType == 1){
                            _this.height = _this.scale[0] / _this.scale[1] * _this.width;
                            $("#imgEditSetHeight").val(_this.height);
                        }else if(changeType == 2){
                            _this.width = _this.scale[1] / _this.scale[0] * _this.height;
                            $("#imgEditSetWidth").val(_this.height);
                        }
                        if(_this.radius >= _this.height || _this.radius >= _this.width){
                            _this.radius = Math.min(_this.width,_this.height) / 2;
                            $("#imgEditSetRadius").val(_this.radius);
                        }
                    }
                    _this.show();
                    _this.prevView();
                })
                //宽
                $("#imgEditSetWidth").keyup(function(){
                    if(!_this.editType.width) return false;
                    changeType = 1;
                    if(this.value >= 0 && this.value <= width){
                        _this.width = -(-this.value);
                        _this.height = !_this.scale ? _this.height : _this.scale[1] / _this.scale[0] * _this.width;
                        if(_this.radius >= _this.height || _this.radius >= _this.width){
                            _this.radius = Math.min(_this.width,_this.height) / 2;
                            $("#imgEditSetRadius").val(_this.radius);
                        }
                        $("#imgEditSetHeight").val(_this.height);
                    }else{
                        this.value = _this.width;
                    }
                    _this.show();
                    _this.prevView();
                })
                //高
                $("#imgEditSetHeight").keyup(function(){
                    if(!_this.editType.height) return false;
                    changeType = 2;
                    if(this.value >= 0 && this.value <= height){
                        _this.height = -(-this.value);
                        _this.width = !_this.scale ? _this.width : _this.scale[0] / _this.scale[1] * _this.height;
                        if(_this.radius >= _this.height || _this.radius >= _this.width){
                            _this.radius = Math.min(_this.width,_this.height) / 2;
                            $("#imgEditSetRadius").val(_this.radius);
                        }
                        $("#imgEditSetWidth").val(_this.width);
                    }else{
                        this.value = _this.height;
                    }
                    _this.show();
                    _this.prevView();
                })
                //圆角
                $("#imgEditSetRadius").keyup(function(){
                    if(!_this.editType.radius) return false;
                    if(this.value >= 0){
                        _this.radius = this.value >= _this.width / 2 || this.value >= _this.height / 2 ? Math.min(_this.width,_this.height) / 2 : -(-this.value);
                    }else{
                        this.value = _this.radius;
                    }
                    _this.show();
                    _this.prevView();
                })
                //原图压缩
                _this.imgSlip = new _this.Slip($("#img_slipMove"),$("#img_slipClick"),$("#img_slipPre"),function(res){
                    _this.imgSize[2] = res;
                    $("#img_slipText").html("(" + Math.ceil(_this.imgSize[0] * res / 100) + "*" + Math.ceil(_this.imgSize[1] * res / 100) + ")");
                    _this.show();
                },function(){
                    _this.prevView();
                },function(p){
                    if(p <= 50){
                        return p * 2;
                    }else{
                        return (1000 - 100) / 50 * (p - 50) + 100;
                    }
                })
                //质量
                _this.compressSlip = new _this.Slip($("#compress_slipMove"),$("#compress_slipClick"),$("#compress_slipPre"),function(res){
                    _this.compress = res / 100;
                    _this.show();
                },function(){
                    _this.prevView();
                })
                //背景透明
                $("#checkMimeType").change(function(){
                    if(!this.checked){
                        _this.mimeType = "jpeg";
                        $("#imgEditBoxImg").css("background","#fff");
                    }else{
                        _this.mimeType = "png";
                        $("#imgEditBoxImg").css("background","url('')");
                    }
                    _this.show();
                    _this.prevView();
                })
                //推荐
                $("#imgEditRecom").click(function(){
                    _this.width = width;
                    $("#imgEditSetWidth").val(_this.width);
                    _this.radius = radius || 0;
                    $("#imgEditSetRadius").val(_this.radius);
                    _this.imgMove = [0,0];//图片移动量
                    _this.compressSlip.set(92);
                    var setImgSize = a.setImgSize({
                        w:width,
                        h:height,
                        _w:_this.imgSize[0],
                        _h:_this.imgSize[1]
                    })
                    //var p = _this.imgSize[0] <= width ? 50 : width / _this.imgSize[0] * 50;
                    var p = setImgSize[0] / _this.imgSize[0] * 50;
                    _this.height = height;
                    $("#imgEditSetHeight").val(_this.height);
                    _this.imgSize[2] = p;//原图数据 长度3 0:宽，1:高，2:压缩比
                    _this.imgSlip.set(p);
                    _this.prevView();
                })
                //获取初始图片信息
                $("#imgEditBoxImg").append(_this.canvasObj);
                var left = 0,top = 0,_left = 0,_top = 0;
                $("#imgEditBoxImg").bind("mousedown",windowBindMove);
                function windowBindMove(e){
                    left = e.clientX;
                    top = e.clientY;
                    _left = _this.imgMove[0];
                    _top = _this.imgMove[1];
                    $("body").addClass("unSelect");
                    $(window).bind("mousemove",windowMove);
                    $(window).bind("mouseup",unBindWindowMove);
                    $(window).bind("keydown",windowKeypress);
                }
                function windowMove(e){
                    var l = e.clientX - left;
                    var t = e.clientY - top;
                    _this.imgMove = [_left + l,_top + t];
                    _this.show();
                }
                function unBindWindowMove(e){
                    $("body").removeClass("unSelect");
                    $(window).unbind("mousemove",windowMove);
                    $(window).unbind("mouseup",unBindWindowMove);
                    _this.prevView();
                }
                $("#imgEditBoxImg").bind("mouseout",function(){
                    $(window).unbind("keydown",windowKeypress);
                });
                function windowKeypress(e){
                    switch(e.which){
                        case 38://上
                            _this.imgMove[1] --;
                            break;
                        case 40://下
                            _this.imgMove[1] ++;
                            break;
                        case 37://左
                            _this.imgMove[0] --;
                            break;
                        case 39://右
                            _this.imgMove[0] ++;
                            break;
                        default:
                            break;
                    }
                    _this.show();
                }
                _this.imgMove = [0,0];//图片移动量
                _this.imgSlip.set(p);
                _this.compressSlip.set(_this.compress * 100);
                _this.prevView();
            }})
        }
        _this.img.src = _this.imgString;
    }
}
//Imgedit end
//formSubmit begin
//form表单提交数据
a.formSubmit = function(url,fn,args){
    args = args || {};
    window.iframeUrl = window.iframeUrl || 'iframe.html';
    args.noBtns = args.noBtns || true;
    args.cancleFn = function(){
        window._fromUpladFn = null;
    }
    window._fromUpladFn = function(data){
        if(!data){
            var iframeContent = $("#uploadIframe")[0].contentWindow;
            var html = "<form enctype='multipart/form-data' action='" + url + "' method='" + (!args.meth ? "POST" : args.meth) + "' style='text-align:center;' id='uploadData'>";
            if(args.form) html += args.form;
            if(args.formDataAppend){
                for(var key in args.formDataAppend){
                    html += "<input type='hidden' id='" + key + "' value='" + args.formDataAppend[key] + "' name='" + key + "' />";
                }
            }
            html += "<input type='hidden' id='returnUrl' value='' name='returnUrl' />";
            html += "<div style='text-align:right;'><input value='确定' id='submit' style='margin-top:10px;border:none;background:#00b7ee;color:#fff;padding:3px 13px;cursor:pointer;' type='submit' /></div>";
            html += "</form>";
            iframeContent.formSubmit(html,{initFn:function(){
                if(args.formInitFn) args.formInitFn(iframeContent,$("#submit",iframeContent.document),$("#uploadData",iframeContent.document));
            }});
        }else{
            fn(data);
            window._fromUpladFn = null;
            if(w && w.close) w.close();
        }
    }
    var w = a.confirmx("<iframe width='90%' src='" + iframeUrl + "?_=" + (new Date().only()) + "' scrolling='no' height='100' frameborder='0' border='0' marginwidth='0' marginheight='0' id='uploadIframe'></iframe>",function(){},args);
}
//formSubmit end
//upload begin
a.upload = function (url,fn,args) {
    args = args || {};
    var multiple = args.multiple ? args.multiple : "";
    var timesFn = args.timesFn ? args.timesFn : "";
    var maxSize = args.maxSize != undefined ? args.maxSize : 10 * 1024 * 1024;
    var header = args.header ? args.header : [];
    var index = 0;
    var reses = [];
    var reg = /^(.+)\.(.+)$/;
    var filesData = [];
    var errorFileType = [];
    var filesName = [];
    var overSizeFile = [];//超出大小图片
    var accept = $("#upLoadInput").attr("accept");
    if(args.Blob) {//自动上传
        uploadFn(args.Blob,args.BlobMime);
        return false;
    }
    if ($("#upLoadInput").size() > 0) $("#upLoadInput").remove();
    if(!!window.ActiveXObject || "ActiveXObject" in window){//IE系列无法新上传
        if(args.canIframe){
            args.meth = "POST";
            args.form = "<div style='height:60px;'><div><input id='file' type='file' name='file' style='margin-top:25px;' /></div></div>";
            args.noCover = true;
            args.title = "上传文件";
            args.formInitFn = function(win,submit,uploadData){
                submit.click(function(){
                    if($("#file",win.document).val() == ""){
                        a.alertx("请选择上传文件");
                        return false;
                    }
                    submit.hide();
                    setTimeout(function(){uploadData.html("<div style='line-height:100px;'>上传中...请稍后</div>");},100);
                    if(args.timesFn) args.timesFn(iframeContent);
                })
            }
            a.formSubmit(url,fn,args);
        }else{
            a.alertx("不支持的浏览器<br />请使用最新的谷歌或火狐浏览器");
        }
        return false;
    }
    $("body").append("<input " + multiple + " id='upLoadInput' type=\"file\" style='display:none;' />");
    $("#upLoadInput").click();
    function uploadFn(files,BlobMime){
        var imgEdit = args.imgEdit ? args.imgEdit : undefined;
        if(imgEdit && files[index] && files[index].type.indexOf("image") > -1){
            var iedit = new a.Imgedit(imgEdit.width,imgEdit.height,imgEdit.scale,imgEdit.radius,imgEdit.editType);
            iedit.maxSize = maxSize;
            iedit.open(files[index],function(res){
                if(res){
                    _do(iedit.dataBlob,iedit.mimeType);
                }else{
                    _do();
                }
            });
        }else{
            _do();
        }
        function _do(obj,mime){
            if(!files[index]) {
                a.alertx("上传文件不存在");
                return false;
            }
            var formData = new FormData();
            accept = accept ? accept.toUpperCase() : accept;
            if($("#upLoadBox").size() == 0) $("body").append("<div id='upLoadBox'></div>");
            var filesiName = files[index].name || (new Date().only() + '.' + BlobMime);
            var _fileName = !mime ? filesiName : filesiName.replace(reg,"$1." + mime);
            var _fileSize = !obj ? files[index].size : obj.size;
            if (accept && accept.indexOf(_fileName.replace(reg, "$2").toUpperCase()) == -1) errorFileType.push(_fileName);
            if(maxSize && _fileSize > maxSize) overSizeFile.push(_fileName);
            if (errorFileType.length > 0) {
                a.alertx(errorFileType.join(",") + " 文件类型不符，请选择正确的文件类型");
                return false;
            }
            if (overSizeFile.length > 0) {
                a.alertx(overSizeFile.join(",") + " 过大,请重新选择");
                return false;
            }
            upFile();
            function upFile(){
                var upLoadId = "upLoadId" + new Date().only();
                var filesiName = files[index].name || (upLoadId + '.' + BlobMime);
                var _fileName = !mime ? filesiName : filesiName.replace(reg,"$1." + mime);
                filesData.push(files[index]);
                filesName.push(_fileName);
                if(args.formDataAppend){
                    for(var key in args.formDataAppend){
                        if(typeof args.formDataAppend[key] == 'function'){
                            formData.append(key, args.formDataAppend[key](files[index]),_fileName);
                        }else{
                            formData.append(key, args.formDataAppend[key]);
                        }
                    }
                }
                formData.append("file", !obj ? files[index] : obj,_fileName);
                var showName = _fileName.replace(/^(.{1,10})(.*)$/,function($0,$1,$2){
                    if($2.length > 3){
                        return $1 + "...";
                    }else{
                        return $0;
                    }
                });
                $("#upLoadBox").append("<div class='upLoad' title='" + showName + "' id='" + upLoadId + "'><span class='upLoad_name'>正在上传 " + showName + "</span><div class='upLoad_loaded'></div><span class='upLoad_close' title='取消'>x</span></div>");
                var isOver = false;
                var ajax = new a.Ajax(url,function(res){
                    isOver = true;
                    $("#" + upLoadId).find(".upLoad_name").html(res.errorMsg ? (showName + " 上传失败," + res.errorMsg) : (showName + " 上传完成"));
                    $("#" + upLoadId).find(".upLoad_loaded").css({animation:'none'});
                    $("#upLoadInput").remove();
                    reses.push(res);
                    closeNode(5000);
                },{header:header,loading:true,meth:"POST",data:formData,progress:function(e){
                    $("#" + upLoadId).find(".upLoad_loaded").css({width:Math.round(e.loaded / e.total * 100) + "%"});
                }});
                if(timesFn) timesFn(upLoadId);
                if(args.beforeAction) {
                    args.beforeAction(formData,files[index].name ? files[index] : {name:filesiName},function(){
                        ajax.action();
                    },ajax);
                }else{
                    ajax.action();
                }
                $("#" + upLoadId).find(".upLoad_close").click(function(){
                    if(!isOver){
                        ajax.abort();
                    }else{
                        remove();
                    }
                })
                function closeNode(times){
                    if(index < files.length - 1){
                        index ++;
                        uploadFn(files,BlobMime);
                    }else{
                        fn(!multiple ? reses[0] : reses, filesData);
                    }
                    setTimeout(function(){
                        remove();
                    },times || 100)
                }
                function remove(){
                    $("#" + upLoadId).animate({opacity:0},1000,function(){
                        $("#" + upLoadId).remove();
                        if($(".upLoad").size() == 0){
                            $("#upLoadBox").remove();
                        }
                    })
                }
            }
        }
    }
    $("#upLoadInput").change(function () {
        if (this.value) uploadFn(document.getElementById('upLoadInput').files);
    })
}
//upload end
//TreeModel begin
//树形结构
a.TreeModel = function(obj){
    var _this = this;
    this.levelMax = 3;//最大层数
    this.data = {};
    this.SQLite = "";
    this.dataModel = {};
    this.dataModelConfig = {};
    this.levelConfig = [];
    this.editable = false;
    this.loadFn = "";
    this.errorFn = "";//出错请求
    this.getAjax = function(type,_dataModel,n,fn,actionObj){
        var confirmxConfig = a.clone(this.dataModelConfig.confirmx);
        var inputHtml = "";//提示框内容
        var verifyArr = [];//需要输入项
        var action = "";
        var req = {};
        if(type == 1){//新增
            action = _this.levelConfig[n].res.add;
        }else if(type == 2){//修改
            action = _this.levelConfig[n].res.edit;
        }else if(type == 3){//删除
            action = _this.levelConfig[n].res.del;
        }
        //初始化参数
        for(var k in this.dataModel){
            req[k] = this.dataModel[k];
            if(_dataModel[k] != undefined){
                req[k].vaule = _dataModel[k];
            }
            if(this.dataModel[k].input){
                if(type == 1){//新增
                    inputHtml += ("<div>" + this.dataModel[k].input.title + "<br />" + this.dataModel[k].input.html + "</div>")._eval(_dataModel,this.dataModel[k].input.htmlEval);
                    verifyArr.push(k);
                }else if(type == 2){//修改
                    inputHtml += ("<div>" + this.dataModel[k].input.title + "<br />" + this.dataModel[k].input.html + "</div>")._eval(_dataModel,this.dataModel[k].input.htmlEval);
                    verifyArr.push(k);
                }else if(type == 3){
                    if(actionObj){
                        confirmxConfig.titleHeight = 0;
                        confirmxConfig._h = 120;
                        confirmxConfig._w = 200;
                        confirmxConfig.styles = confirmxConfig.styles || {};
                        confirmxConfig.styles.bottom = confirmxConfig.styles.bottom || '';
                        confirmxConfig.styles.center = confirmxConfig.styles.top || '';
                        confirmxConfig.styles.box = confirmxConfig.styles.box || '';
                        confirmxConfig.styles.bottom += 'border-top:none;';
                        confirmxConfig.styles.center += 'border-top:none;';
                        confirmxConfig.styles.box += 'left:' + (actionObj.offset().left - 150) + 'px;top:' + (actionObj.offset().top - 110) + 'px;';
                    }
                    inputHtml = "<div>确定删除?</div>";
                }
            }
        }
        for(var k in action.req){
            req[k] = action.req[k];
        }
        //获取输入参数
        //弹出框
        a.confirmx('<div style="text-align:left;margin-left:55px;">' + inputHtml + '</div>',function(){
            //验证并赋值
            var isOk = true;
            var errorMsg = "";
            for(var i = 0; i < verifyArr.length; i ++){
                var val = req[verifyArr[i]].input.val();
                if(val.result){
                    req[verifyArr[i]].vaule = val.vaule;
                }else{
                    isOk = false;
                    if(val.msg) errorMsg += val.msg;
                }
            }
            if(isOk){
                //强制修改参数及url
                for(var k in req){
                    if(req[k].vaule != undefined){
                        req[k] = req[k].vaule;
                    }else{
                        if(typeof req[k] == "object"){
                            req[k] = "";
                        }
                    }
                }
                var url = action.url._eval(req);
                //ajax请求.
                var ajaxConfig = action.ajaxConfig || {};
                ajaxConfig.meth = action.meth;
                ajaxConfig.data = req;
                var ajax = new a.Ajax(url,function(res){
                    if(res && res[action.res.successKey]){
                        fn(res);
                    }else{
                        if(res && res.errorMsg){
                            a.alertx("操作失败!" + res.errorMsg);
                        }else{
                            a.alertx("操作失败，未知错误！");
                        }
                    }
                },ajaxConfig);
                ajax.action();
            }else{
                if(errorMsg) a.alertx(errorMsg);
            }
        },confirmxConfig)
    }
    this.active = [0];//激活状态数组
    this.windowScrollTop = 0;
    this.append = function(id,n,_obj,clickData){
        var activeClass = !_this.levelConfig[n].res.activeClass ? "active" : _this.levelConfig[n].res.activeClass;
        _obj = !_obj ? obj : _obj;
        if(id != undefined && this.data["num" + id]){
            var _data = this.data["num" + id];
            var html = "";
            if(_this.levelConfig[n].res.beforeFn) _this.levelConfig[n].res.beforeFn(clickData,_this.active);
            for(var i = 0; i < _data.length; i++) html += _this.levelConfig[n].res.html._eval(_data[i],_this.levelConfig[n].res.htmlEval);
            if(this.editable) html += _this.levelConfig[n].res.add.html;
            _obj.html(html + _this.levelConfig[n].res.style);
            if(n > 0) {
                _this.active[n - 1].childBox = _obj;
                _this.active[n - 1].id = id;
            }
            _obj.show();
            $(window).scrollTop(this.windowScrollTop);
            if(this.editable){
                //新增
                _obj.find("." + _this.levelConfig[n].res.add.btnClass).eq(0).click(function(){
                    var o = {};
                    for(var k in _this.dataModel) o[k] = '';
                    o[_this.levelConfig[n].pidKey] = id;
                    _this.getAjax(1,o,n,function(){
                        _this.data["num" + id] = undefined;//清除数据重新从服务器拉取
                        _this.getData(n,id,_obj,undefined,clickData);
                    })
                })
            }
            _obj.children().each(function(i){
                var $this = $(this);
                //点击图标
                var clickObj = !_this.levelConfig[n].res.clickBox ? $(this) : $(this).find("." + _this.levelConfig[n].res.clickBox).eq(0);
                if(_this.levelConfig[n].res.icon){
                    $(this).find("." + _this.levelConfig[n].res.icon[0]).eq(0).click(function(){
                        var open = $(this).attr("open");
                        if(open == "open"){
                            if(_this.levelConfig[n].res.icon.length > 2){
                                $(this).attr("src",_this.levelConfig[n].res.icon[1]);
                            }
                            $(this).removeAttr("open");
                            var obj  = !_this.levelConfig[n + 1].res.obj ? $this.find("." + _this.levelConfig[n].res.childBox).eq(0) : _this.levelConfig[n + 1].res.obj;
                            obj.html("");
                        }else{
                            _this.clickFn(n,i);
                        }
                    })
                }
                //点击加载
                clickObj.bind(_this.levelConfig[n].res.clickEventType ? _this.levelConfig[n].res.clickEventType : "click",function(){
                    if(typeof _this.levelConfig[n].res.defaultClickFn == 'function' && !_this.levelConfig[n].res.defaultClickFn(_data[i])) return false;
                    _this.clickFn(n,i);
                })
                var editBtn,deleteBtn;
                if(_this.levelConfig[n].res.edit && _this.levelConfig[n].res.edit.btnClass){
                    editBtn = $(this).find("." + _this.levelConfig[n].res.edit.btnClass).eq(0);
                    editBtn.hide();
                }
                if(_this.levelConfig[n].res.del && _this.levelConfig[n].res.del.btnClass){
                    deleteBtn = $(this).find("." + _this.levelConfig[n].res.del.btnClass).eq(0);
                    deleteBtn.hide();
                }
                if(_this.editable){
                    $(this).children().eq(0).mouseover(function(){
                        editBtn.show();
                        deleteBtn.show();
                        if(typeof _this.levelConfig[n].res.mouseover == 'function') _this.levelConfig[n].res.mouseover(i);
                    })
                    $(this).children().eq(0).mouseout(function(){
                        editBtn.hide();
                        deleteBtn.hide();
                        if(typeof _this.levelConfig[n].res.mouseout == 'function') _this.levelConfig[n].res.mouseout(i);
                    })
                    //操作项
                    var actions = _this.levelConfig[n].res.actions;
                    if(actions && actions.length > 0){
                        var actionsHtml = '';
                        for(var j = 0; j < actions.length; j ++){
                            actionsHtml += '<div class="treeActionDiv">';
                            if(actions[j].html){
                                actionsHtml += actions[j].html;
                            }else{
                                actionsHtml += '<label class="treeActionLabel">{label}</label><span class="treeActionIcon"><img src="{icon}" /></span><div class="clear"></div>'._eval(actions[j]);
                            }
                            actionsHtml += '</div>';
                        }
                        $this.find('.showActionsBox').html(actionsHtml);
                        $this.find('.treeActionDiv').each(function(j){
                            if(actions[j].html){
                                actions[j].action($(this),_data,i);
                            }else{
                                $(this).click(function(){
                                    actions[j].action($(this),_data,i);
                                })
                            }
                        })
                        var thisTimer;
                        $(this).find('.showActions').mouseover(function(e){
                            if(thisTimer) clearTimeout(thisTimer);
                            $this.find('.showActionsBox').show();
                        })
                        $(this).find('.showActions').mouseout(function(){
                            thisTimer = setTimeout(function(){
                                $this.find('.showActionsBox').hide();
                            },500)
                        })
                        $this.find('.showActionsBox').mouseover(function(){
                            clearTimeout(thisTimer);
                        })
                        $this.find('.showActionsBox').mouseout(function(){
                            thisTimer = setTimeout(function(){
                                $this.find('.showActionsBox').hide();
                            },500)
                        })
                    }
                    //修改
                    editBtn.click(function(){
                        _this.getAjax(2,_this.data["num" + id][i],n,function(){
                            _this.data["num" + id] = undefined;//清除数据重新从服务器拉取
                            _this.getData(n,id,_obj,undefined,clickData);
                        })
                    })
                    //删除
                    deleteBtn.click(function(){
                        _this.getAjax(3,_this.data["num" + id][i],n,function(){
                            _this.data["num" + id] = undefined;//清除数据重新从服务器拉取
                            _this.getData(n,id,_obj,undefined,clickData);
                        },deleteBtn)
                    })
                }
            })
            if(_this.levelConfig[n].res.endFn) _this.levelConfig[n].res.endFn(_this.active);
        }
    }
    this.clickFn = function(n,i){
        var activeClass = !_this.levelConfig[n].res.activeClass ? "active" : _this.levelConfig[n].res.activeClass;
        var $this = obj.children().eq(i);
        if(_this.active[n - 1] && _this.active[n - 1].childBox) $this = _this.active[n - 1].childBox.children().eq(i);
        var id = _this.levelConfig[0].req[_this.levelConfig[0].pidKey];
        if(_this.active[n - 1] && _this.active[n - 1].id) id = _this.active[n - 1].id;
        if(_this.levelConfig[n].res.clickFn) _this.levelConfig[n].res.clickFn(_this.active);
        _this.windowScrollTop = $(window).scrollTop();
        if(_this.active[n]) _this.active[n].obj.removeClass(activeClass);
        if(_this.levelConfig[n].res.childBoxOnly && _this.active[n] && _this.active[n].flog != i && _this.active[n].childBox) _this.active[n].childBox.hide();
        if(_this.levelConfig[n].res.icon && _this.active[n] && _this.active[n].iconObj) _this.active[n].iconObj.attr("src",_this.levelConfig[n].res.icon[1]);
        _this.active[n] = {iconObj:_this.levelConfig[n].res.icon ? $this.find("." + _this.levelConfig[n].res.icon[0]).eq(0) : "",obj:$this,flog:i};
        _this.active[n].obj.addClass(activeClass);
        if(n + 1 == _this.levelMax) {
            if(_this.loadFn) _this.loadFn(_this.data["num" + id][i][_this.levelConfig[n].idKey],id,"",_this.data["num" + id][i],n + 1);//进行其他操作
        }else{
            _this.levelConfig[n + 1] = !_this.levelConfig[n + 1] ? a.clone(_this.levelConfig[n]) : _this.levelConfig[n + 1];
            _this.getData(n + 1,_this.data["num" + id][i][_this.levelConfig[n].idKey],!_this.levelConfig[n + 1].res.obj ? $this.find("." + _this.levelConfig[n].res.childBox).eq(0) : _this.levelConfig[n + 1].res.obj,id,_this.data["num" + id][i]);
            if(_this.levelConfig[n].res.icon) {
                if(_this.levelConfig[n].res.icon.length > 2) _this.active[n].iconObj.attr("src",_this.levelConfig[n].res.icon[2]);
                _this.active[n].iconObj.attr("open","open");
            }
        }
    }
    this.getting = "";
    this.getData = function(n,id,obj,_pid,clickData){
        if(id != undefined){
            this.levelConfig[n].req[this.levelConfig[n].pidKey] = id;
        }else{
            id = this.levelConfig[n].req[this.levelConfig[n].pidKey];
        }
        if(id != undefined && this.data["num" + id]){
            _this.append(id,n,obj,clickData);
            if(this.loadFn) this.loadFn(id == undefined ? this.levelConfig[n].req[this.levelConfig[n].pidKey] : id,_pid,obj,clickData,n);//进行其他操作
        }else{
            this.getting = id;
            if(this.SQLite){
                this.SQLite.find(this.levelConfig[n].req,function(res){
                    showData(res);
                })
            }else{
                if(obj) obj.html("<div  class='loadBeginMsg'>获取中...</div>");
                var ajax = new a.Ajax(this.levelConfig[n].url,function(res,err,id){
                    if(id == _this.getting){
                        showData(res);
                    }
                },{meth:this.levelConfig[n].meth,data:this.levelConfig[n].req});
                ajax.action(id);
            }
        }
        function showData(res){
            if(res && !res.errorMsg){
                var arr = res;
                if(_this.levelConfig[n].res.arrKey){
                    for(var i = 0; i < _this.levelConfig[n].res.arrKey.length; i++){
                        arr = arr[_this.levelConfig[n].res.arrKey[i]];
                    }
                }
                _this.data["num" + id] = arr;
                _this.append(id,n,obj,clickData);
            }else{
                var msg = "请求失败";
                if(res && res.errorMsg) msg += "," + res.errorMsg;
                if(obj) obj.html("<div  class='loadBeginMsg'>" + msg + "</div>");
                a.alertx(msg,function(){
                    if(_this.errorFn) _this.errorFn(id == undefined ? _this.levelConfig[n].req[_this.levelConfig[n].pidKey] : id,_pid,obj,clickData,n,res);//获取出错操作
                });
            }
            if(_this.loadFn) _this.loadFn(id == undefined ? _this.levelConfig[n].req[_this.levelConfig[n].pidKey] : id,_pid,obj,clickData,n);//进行其他操作
        }
    }
}
//TreeModel end
//ScrollEvent begin
a.ScrollEvent = {
    args:[],
    bindEvent:false,
    init:function(){
        var args = this.args,preTop = 0;
        $(window).scroll(function(e){
            var scrollTop = $(this).scrollTop();
            for(var i = 0; i < args.length; i ++){
                if(args[i][0] && args[i][0] <= scrollTop) args[i][1](scrollTop,preTop);
                if(args[i][0] && args[i][0] > scrollTop) args[i][2](scrollTop,preTop);
            }
            preTop = scrollTop;
        })
    },
    set:function(){//bool是否设置时执行即页面加载执行
        var scrollTop = $(window).scrollTop();
        if(arguments.length > 0) {
            for(var i = 0; i < arguments.length; i ++) {
                this.args.push(arguments[i]);
                if(scrollTop >= arguments[i][0]){
                    arguments[i][1](scrollTop,0);
                }else{
                    arguments[i][2](scrollTop,0);
                }
            }
        }
        if(!this.bindEvent){
            this.init();
            this.bindEvent = true;
        }
    }
}
//ScrollEvent end
//WindowResize begin
a.WindowResize = {
    args:[],
    bindEvent:false,
    init:function(){
        var args = this.args;
        $(window).bind('resize',function(){
            var width = $(window).width();
            var height = $(window).width();
            for(var i = 0; i < args.length; i ++) if(typeof args[i] == 'function') args[i](width,height);
        })
    },
    set:function(){
        if(arguments.length > 0) for(var i = 0; i < arguments.length; i ++) this.args.push(arguments[i]);
        if(!this.bindEvent){
            this.init();
            this.bindEvent = true;
        }
    }
}
//WindowResize end
//loadImg begin
a.loadImg = function(objs,args){
    args = args || {};
    if(objs.each){
        var err = args.err || '';
        var errImg = args.errImg || "images/errImg.png";
        err = args.err == false ? '' : args.err;
        objs.each(function(i){
            var $this = $(this);
            if(args.drag === false) {
                $this.attr('ondragstart','return false;');
                $this.attr('onselectstart','return false;');
                $this.css('-moz-user-select','none');
                $this.css('overflow','hidden');
            }
            var imgSrc = $this.attr(args.attrName ? args.attrName : "imgSrc");
            if(!imgSrc){
                if(err){
                    $this.html(err);
                    $this.css("background-image","none");
                }
            }else{
                load(imgSrc,$this);
            }
        })
        function load(url,$this,err){
            var img = document.createElement("Img");
            var width = $this.width();
            var height = $this.height();
            img.onload = function(){
                if(width && height){
                    var site = a.setImgSize({_w:width,_h:height,w:img.width,h:img.height,type:args.type});
                    img.width = site[0];
                    img.height = site[1];
                    img.style.position = 'relative';
                    img.style.top = site[2] + "px";
                    img.style.left = site[3] + "px";
                }
                if(args.attr) for(var k in args.attr) img.setAttribute(k,args.attr[k]);
                $this.html(img);
                $this.css("background-image","none");
            }
            if(!err){
                img.onerror = function(){
                    if(err){
                        $this.html(err);
                    }else{
                        load(errImg,$this,true);
                    }
                }
            }
            img.src = url;
            $this.removeAttr((args.attrName ? args.attrName : "imgSrc"));
        }
    }
}
//loadImg end
//Lists begin
a.Lists = function(args){
    var _this = this;
    this.id = new Date().only();
    this.paging = function(){
        var pageNum = args.list.pageNum - 1;
        //处理分页
        args.paging.html("<font style='margin-right:10px;color:#999999;float:left;'>共 " + args.list.total + " 条数据" + (args.changePageSize == false ? "" :",每页<select id='pageSizeSelect" + this.id + "' style='border-color:#e4e4e4;width:50px;margin:0px 5px;'><option value='5' " + (args.list.pageSize == 5 ? "selected" : "") + ">5</option><option value='10' " + (args.list.pageSize == 10 ? "selected" : "") + ">10</option><option value='15' " + (args.list.pageSize == 15 ? "selected" : "") + ">15</option><option value='20' " + (args.list.pageSize == 20 ? "selected" : "") + ">20</option><option value='50' " + (args.list.pageSize == 50 ? "selected" : "") + ">50</option><option value='100' " + (args.list.pageSize == 100 ? "selected" : "") + ">100</option></select>条</font>"));
        $("#pageSizeSelect" + this.id).change(function(){
            if(localStorage && args.urlId) {
                localStorage[args.urlId] = this.value;
                args.list.pageSize = this.value;
            }else{
                args.list.pageSize = this.value;
            }
            args.list.reLoad();
        });
        if (args.list.total > args.list.pageSize) {
            var nums = Math.ceil(args.list.total / args.list.pageSize);
            var btns = "<span class='pagaBtn pagaBtnFirst'>首页</span><span class='pagaBtn'><</span>";
            var flogNume = 3;
            if (pageNum - 1 >= flogNume) btns += "<span class='pagaBtn'>...</span>";
            for (var i = 0; i < nums; i++) {
                if (i > (pageNum - 1) - flogNume && i < (pageNum - 1) + flogNume) {
                    btns += "<span class='pagaBtn" + (i + 1 == pageNum ? " pagaBtnActive" : "") + "'>" + (i + 1) + "</span>";
                }
            }
            if (nums - (pageNum - 1) > flogNume) btns += "<span class='pagaBtn'>...</span>";
            btns += "<span class='pagaBtn'>></span><span class='pagaBtn pagaBtnLast'>尾页</span>";
            args.paging.append(btns);
            var btnsNum = args.paging.find("span").size();
            args.paging.find("span").each(function (i) {
                switch (i) {
                    case 0:
                        $(this).attr("num", 1);
                        break;
                    case 1:
                        $(this).attr("num", pageNum == 1 ? 1 : pageNum - 1);
                        break;
                    case btnsNum - 1:
                        $(this).attr("num", nums);
                        break;
                    case btnsNum - 2:
                        $(this).attr("num", pageNum == nums ? nums : pageNum + 1);
                        break;
                    default :
                        $(this).attr("num", $(this).html());
                        break;
                }
                $(this).click(function () {
                    pageNum = -(-$(this).attr("num"));
                    if (pageNum >= 0) args.list.refresh(_this.append,pageNum);
                });
            });
        }
    }
    this.changeStatu = function(){
        if(args.status){
            if(args.list.status.loading || args.list.status.refreshing){
                args.status.html('<div class="loadStatu loads_loading">加载中...</div>');
            }else{
                if(args.list.status.beforeLoad){
                    args.status.html('<div class="loadStatu loads_beforeLoad">点击获取数据</div>');
                }else if(args.list.status.noData){
                    args.status.html('<div class="loadStatu loads_noData">抱歉,未找到相应内容</div>');
                }else if(args.list.status.allLoaded){
                    args.status.html('<div class="loadStatu loads_allLoaded">已全部加载完成</div>');
                }else{
                    args.status.html('<div class="loadStatu loads_load">点击加载更多</div>');
                }
            }
            args.status.find('.loads_beforeLoad,.loads_noData,.loads_load').click(function(){
                args.list.load(_this.append);
            })
        }
    }
    this.append = function(){
        var html = '';
        for(var i = 0; i < args.list.data.length; i ++) html += args.template._eval(args.list.data[i],args.templateEval);
        html += args.clear || '<div style="clear:both;"></div>';
        if(args.paging){
            args.obj.html(html);
            _this.paging();
        }else{
            args.obj.append(html);
        }
        _this.changeStatu();
        if(args.loaded) args.loaded();
    }
    args.list.beforeLoadFn = this.changeStatu;
    args.list.load(this.append);
}
//Lists end
//picBox begin
a.picBox = function(img,args){
    $('body').append('<div id="_picBoxClose" style="position:fixed;z-index:4999;color:#fff;right:8px;top:8px;padding:3px 10px;">X</div><div style="position:fixed;z-index:4998;left:0px;top:0px;right:0px;bottom:0px;background:rgba(0,0,0,0.5);display:flex;justify-content: center;align-items: center;" id="_picBox"><img style="max-width:100%;" id="_picBoxImg" src="' + img + '" /></div>');
    var x = [],y = [],s = 0;scale = 1,_left = 0,_top = 0,scaleing = false;
    a.on($('#_picBox')[0],'touch',function(e){
        $('#_picBox').remove();
        $('#_picBoxClose').remove();
        e.preventDefault();
    },{move:function(e){
        e.preventDefault();
    }})
    a.on($('#_picBoxClose')[0],'click',function(e){
        $('#_picBox').remove();
        $('#_picBoxClose').remove();
    })
    a.on($('#_picBoxImg')[0],'touch',function(e){
        e.stopPropagation();
        scaleing = false;
    },{move:function(e){
        if(e.changedTouches){
            if(e.changedTouches.length > 1){
                var _x = [e.changedTouches[0].clientX,e.changedTouches[1].clientX];
                var _y = [e.changedTouches[0].clientY,e.changedTouches[1].clientY];
                var _s = Math.sqrt(_x[0] - _x[1]) * (_x[0] - _x[1]) + (_y[0] - _y[1]) * (_y[0] - _y[1]);
                if(_s != 0){
                    scaleing = true;
                    if(_s > s){
                        scale += 0.1;
                    }else{
                        scale -= 0.1;
                        scale = scale < 1 ? 1 : scale;
                    }
                    an();
                    x = _x;
                    y = _y;
                    s = _s;
                }
            }else if(!scaleing){
                var _x = e.changedTouches[0].clientX;
                var _y = e.changedTouches[0].clientY;
                _left += _x - x > 0 ? 3 : -3;
                _top += _y - y > 0 ? 3 : -3;
                an();
                x = _x;
                y = _y;
            }
        }
    }})
    function an(){
        $('#_picBoxImg').css('transform','translate3d(' + _left + 'px, ' + _top + 'px, 0px) scale(' + scale + ', ' + scale + ')');
    }
}
//picBox end